added test

Signed-off-by: Richard Jones <richard@dagger.io>
This commit is contained in:
Richard Jones
2021-10-05 11:57:21 -06:00
parent 46c02c7563
commit 35a86441bf
5 changed files with 195 additions and 71 deletions

View File

@@ -11,21 +11,19 @@ setup() {
@test "doc-1003-get-started" {
setup_example_sandbox
# Set examples private key
"$DAGGER_SANDBOX"/import-tutorial-key.sh
# Follow tutorial
mkdir -p "$DAGGER_SANDBOX"/getting-started/plans
cp -R "$DAGGER_PROJECT"/getting-started/ "$DAGGER_SANDBOX"/getting-started/
dagger --project "$DAGGER_SANDBOX" new 'local' -p "$DAGGER_SANDBOX"/getting-started/plans/local
dagger --project "$DAGGER_SANDBOX" -e 'local' input socket run.socket /var/run/docker.sock
dagger --project "$DAGGER_SANDBOX" -e 'local' input dir app.source "$DAGGER_SANDBOX"
dagger --project "$DAGGER_SANDBOX" -e 'local' up
# Collect url
dagger --project "$DAGGER_SANDBOX" up
url=$(dagger --project "$DAGGER_SANDBOX" query -f text url)
# More commands
dagger --project "$DAGGER_SANDBOX" list
ls -l "$DAGGER_SANDBOX"/s3
dagger --project "$DAGGER_SANDBOX" input list
# Check output
run curl "$url"
assert_output --partial "My Todo app"
until docker inspect --format "{{json .State.Status }}" todoapp | grep -m 1 "running"; do sleep 1 ; done
run curl -f -LI http://localhost:8080
assert_output --partial '200 OK'
docker stop todoapp && docker rm todoapp
}
@test "doc-1004-first-env" {

View File

@@ -0,0 +1,19 @@
package todoapp
import (
"alpha.dagger.io/dagger"
"alpha.dagger.io/docker"
)
// run our todoapp in our local Docker engine
run: docker.#Run & {
ref: push.ref
name: "todoapp"
ports: ["8080:80"]
socket: dagger.#Stream & dagger.#Input
}
// push to our local registry
// this concrete value satisfies the string constraint
// we defined in the previous file
push: target: "localhost:5000/todoapp"

View File

@@ -0,0 +1,36 @@
package todoapp
import (
"alpha.dagger.io/dagger"
"alpha.dagger.io/os"
"alpha.dagger.io/docker"
"alpha.dagger.io/js/yarn"
)
// Build the source code using Yarn
app: yarn.#Package & {
"source": dagger.#Artifact & dagger.#Input
}
// package the static HTML from yarn into a Docker image
image: os.#Container & {
image: docker.#Pull & {
from: "nginx"
}
// app.build references our app key above
// which infers a dependency that Dagger
// uses to generate the DAG
copy: "/usr/share/nginx/html": from: app.build
}
// push the image to a registry
push: docker.#Push & {
// leave target blank here so that different
// environments can push to different registries
target: string
// the source of our push resource
// is the image resource we declared above
source: image
}