From d39cc200ca6c52d89563b97117967f465b7d628e Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Tue, 5 Oct 2021 18:15:38 -0700 Subject: [PATCH] docs: added abililty to run a local registry for todoapp example Signed-off-by: Sam Alba --- docs/learn/1003-get-started.md | 17 +++++++++-------- docs/learn/tests/doc.bats | 2 +- .../tests/getting-started/plans/local/local.cue | 16 +++++++++++++++- docs/learn/tests/helpers.bash | 3 ++- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/docs/learn/1003-get-started.md b/docs/learn/1003-get-started.md index 656a6a36..6b0208b1 100644 --- a/docs/learn/1003-get-started.md +++ b/docs/learn/1003-get-started.md @@ -81,6 +81,7 @@ We will now create the following files: Create the file `plans/todoapp.cue` with the following content: ```cue file=./tests/getting-started/plans/todoapp.cue + ``` This file will define the resources and relationships between them that are common across _all environments_. For example, here we are deploying to our local Docker engine in our `local` environment, but for staging or production as examples, we would deploy the same image to some other container orchestration system such as Kubernetes hosted somewhere out there among the various cloud providers. @@ -125,9 +126,9 @@ dagger -e local input list You should see the following output: ```bash -Input Value Set by user Description -app.source dagger.#Artifact false Application source code -run.socket struct false Mount local docker socket +Input Value Set by user Description +app.source dagger.#Artifact false Application source code +dockerSocket struct false Mount local docker socket ``` Notice that `Set by user` is _false_ for both, because we have not yet provided Dagger with those values. @@ -135,19 +136,19 @@ Notice that `Set by user` is _false_ for both, because we have not yet provided Let’s provide them now: ```shell -dagger -e local input socket run.socket /var/run/docker.sock +dagger -e local input socket dockerSocket /var/run/docker.sock dagger -e local input dir app.source ./ ``` -This defines the `run.socket` as a `socket` input type, and the `app.source` input as a `dir` input type. +This defines the `dockerSocket` as a `socket` input type, and the `app.source` input as a `dir` input type. Now let’s replay the `dagger input list` command: ```bash -Input Value Set by user Description -app.source dagger.#Artifact true Application source code -run.socket struct true Mount local docker socket +Input Value Set by user Description +app.source dagger.#Artifact true Application source code +dockerSocket struct true Mount local docker socket ``` Notice that Dagger now reports that both inputs have been set. diff --git a/docs/learn/tests/doc.bats b/docs/learn/tests/doc.bats index 9b3af3b1..a1a043e8 100644 --- a/docs/learn/tests/doc.bats +++ b/docs/learn/tests/doc.bats @@ -17,7 +17,7 @@ setup() { cp "$DAGGER_PROJECT"/getting-started/plans/local/local.cue "$DAGGER_SANDBOX"/plans/local/local.cue dagger --project "$DAGGER_SANDBOX" new 'local' -p "$DAGGER_SANDBOX"/plans/local - dagger --project "$DAGGER_SANDBOX" -e 'local' input socket run.socket /var/run/docker.sock + dagger --project "$DAGGER_SANDBOX" -e 'local' input socket dockerSocket /var/run/docker.sock dagger --project "$DAGGER_SANDBOX" -e 'local' input dir app.source "$DAGGER_SANDBOX" dagger --project "$DAGGER_SANDBOX" -e 'local' up diff --git a/docs/learn/tests/getting-started/plans/local/local.cue b/docs/learn/tests/getting-started/plans/local/local.cue index 590acffd..d3e0609f 100644 --- a/docs/learn/tests/getting-started/plans/local/local.cue +++ b/docs/learn/tests/getting-started/plans/local/local.cue @@ -5,15 +5,29 @@ import ( "alpha.dagger.io/docker" ) +// docker local socket +dockerSocket: dagger.#Stream & dagger.#Input + // run our todoapp in our local Docker engine run: docker.#Run & { ref: push.ref name: "todoapp" ports: ["8080:80"] - socket: dagger.#Stream & dagger.#Input + socket: dockerSocket +} + +// run our local registry +registry: docker.#Run & { + ref: "registry:2" + name: "registry-local" + ports: ["5000:5000"] + socket: dockerSocket } // push to our local registry // this concrete value satisfies the string constraint // we defined in the previous file push: target: "localhost:5000/todoapp" + +// output the application URL +appURL: "http://localhost:8080/" & dagger.#Output diff --git a/docs/learn/tests/helpers.bash b/docs/learn/tests/helpers.bash index 85334291..394f165c 100644 --- a/docs/learn/tests/helpers.bash +++ b/docs/learn/tests/helpers.bash @@ -40,6 +40,7 @@ setup_example_sandbox() { git -C "$DAGGER_SANDBOX" clone https://github.com/dagger/examples export DAGGER_SANDBOX="$DAGGER_SANDBOX"/examples/todoapp + dagger --project "$DAGGER_SANDBOX" init } @@ -91,4 +92,4 @@ skip_unless_local_kube() { else skip "local kubernetes cluster not available" fi -} \ No newline at end of file +}