docs: added abililty to run a local registry for todoapp example

Signed-off-by: Sam Alba <sam.alba@gmail.com>
This commit is contained in:
Sam Alba 2021-10-05 18:15:38 -07:00
parent 6b74006ddd
commit d39cc200ca
4 changed files with 27 additions and 11 deletions

View File

@ -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&rsquo;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&rsquo;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.

View File

@ -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

View File

@ -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

View File

@ -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
}
}