From 8e300075986f0c2d74d706528a1ff6be474b6d5b Mon Sep 17 00:00:00 2001 From: Christoph Raaflaub Date: Wed, 4 Sep 2024 14:26:57 +0200 Subject: [PATCH] lab 4 updates --- content/en/docs/04/_index.md | 15 +-------------- content/en/docs/04/solution/__init__.py | 20 ++++++++++---------- content/en/docs/04/solution/dagger.json | 12 ++++++++++++ 3 files changed, 23 insertions(+), 24 deletions(-) create mode 100644 content/en/docs/04/solution/dagger.json diff --git a/content/en/docs/04/_index.md b/content/en/docs/04/_index.md index 840bd8b..a8ecf16 100644 --- a/content/en/docs/04/_index.md +++ b/content/en/docs/04/_index.md @@ -42,20 +42,7 @@ dagger install github.com/sagikazarmark/daggerverse/trivy@v0.5.0 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! diff --git a/content/en/docs/04/solution/__init__.py b/content/en/docs/04/solution/__init__.py index 334aca8..1ad5366 100644 --- a/content/en/docs/04/solution/__init__.py +++ b/content/en/docs/04/solution/__init__.py @@ -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.""" @@ -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""" diff --git a/content/en/docs/04/solution/dagger.json b/content/en/docs/04/solution/dagger.json new file mode 100644 index 0000000..dbf0237 --- /dev/null +++ b/content/en/docs/04/solution/dagger.json @@ -0,0 +1,12 @@ +{ + "name": "ClassQuiz", + "sdk": "python", + "dependencies": [ + { + "name": "trivy", + "source": "github.com/sagikazarmark/daggerverse/trivy@5b826062b6bc1bfbd619aa5d0fba117190c85aba" + } + ], + "source": "ci", + "engineVersion": "v0.12.7" +}