Skip to content

Commit

Permalink
lab 4 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
chrira committed Sep 4, 2024
1 parent f29a356 commit 8e30007
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
15 changes: 1 addition & 14 deletions content/en/docs/04/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,7 @@ dagger install github.com/sagikazarmark/daggerverse/[email protected]

Dagger downloaded the Module and added it as dependency to our `dagger.json`:

```json
{
"name": "classquiz",
"sdk": "python",
"dependencies": [
{
"name": "trivy",
"source": "github.com/sagikazarmark/daggerverse/trivy@5b826062b6bc1bfbd619aa5d0fba117190c85aba"
}
],
"source": "ci",
"engineVersion": "v0.12.7"
}
```
{{< readfile file="solution/dagger.json" code="true" lang="JSON" >}}

This way, all the functions provided by the module are available directly in our code - no need to add further imports or anything like that!

Expand Down
20 changes: 10 additions & 10 deletions content/en/docs/04/solution/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ def backend(self, context: dagger.Directory) -> dagger.Container:
.build(context)
)

@function
def redis(self) -> dagger.Service:
"""Returns a redis service from a container built with the given params."""
return (
dag.container()
.from_("redis:alpine")
.with_exposed_port(6379)
.as_service()
)

@function
def postgres(self) -> dagger.Service:
"""Returns a postgres database service from a container built with the given params."""
Expand All @@ -78,16 +88,6 @@ def meilisearch(self) -> dagger.Service:
.as_service()
)

@function
def redis(self) -> dagger.Service:
"""Returns a redis service from a container built with the given params."""
return (
dag.container()
.from_("redis:alpine")
.with_exposed_port(6379)
.as_service()
)

@function
def proxy(self, context: dagger.Directory, proxy_config: dagger.File) -> dagger.Service:
"""Returns a caddy proxy service encapsulating the front and backend services. This service must be bound to port 8000 in order to match some hard coded configuration: --ports 8000:8080"""
Expand Down
12 changes: 12 additions & 0 deletions content/en/docs/04/solution/dagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "ClassQuiz",
"sdk": "python",
"dependencies": [
{
"name": "trivy",
"source": "github.com/sagikazarmark/daggerverse/trivy@5b826062b6bc1bfbd619aa5d0fba117190c85aba"
}
],
"source": "ci",
"engineVersion": "v0.12.7"
}

0 comments on commit 8e30007

Please sign in to comment.