diff --git a/examples/react-netlify/main.cue b/examples/react-netlify/main.cue new file mode 100644 index 00000000..1d7cd991 --- /dev/null +++ b/examples/react-netlify/main.cue @@ -0,0 +1,28 @@ +package main + +import ( + "dagger.io/dagger" + "dagger.io/netlify" + "dagger.io/yarn" +) + +repository: #dagger: compute: [ + dagger.#FetchGit & { + remote: "https://github.com/kabirbaidhya/react-todo-app.git" + ref: "624041b17bd62292143f99bce474a0e3c2d2dd61" + }, +] + +todoApp: netlify.#Site & { + account: { + name: "blocklayer" + token: string // Fill using --input-string todoApp.account.token=XXX + } + + name: "dagger-test" + + contents: yarn.#Script & { + source: repository + run: "build" + } +} diff --git a/examples/simple/simple.cue b/examples/simple/simple.cue index c691d79c..755c8509 100644 --- a/examples/simple/simple.cue +++ b/examples/simple/simple.cue @@ -1,6 +1,4 @@ -// ACME platform: everything you need to develop and ship improvements to -// the ACME clothing store. -package acme +package simple import ( "dagger.io/dagger" diff --git a/stdlib/alpine/alpine.cue b/stdlib/alpine/alpine.cue new file mode 100644 index 00000000..83da22b1 --- /dev/null +++ b/stdlib/alpine/alpine.cue @@ -0,0 +1,30 @@ +package alpine + +import ( + "dagger.io/dagger" +) + +let defaultVersion = "3.13.2@sha256:a75afd8b57e7f34e4dad8d65e2c7ba2e1975c795ce1ee22fa34f8cf46f96a3be" + +#Image: { + package: [string]: true | false | string + version: string | *defaultVersion + + #dagger: compute: [ + dagger.#FetchContainer & { + ref: "index.docker.io/alpine:\(version)" + }, + for pkg, info in package { + if (info & true) != _|_ { + dagger.#Exec & { + args: ["apk", "add", "-U", "--no-cache", pkg] + } + } + if (info & string) != _|_ { + dagger.#Exec & { + args: ["apk", "add", "-U", "--no-cache", "\(pkg)\(info)"] + } + } + }, + ] +} diff --git a/stdlib/netlify/netlify.cue b/stdlib/netlify/netlify.cue index 513d1ab4..2e8ee494 100644 --- a/stdlib/netlify/netlify.cue +++ b/stdlib/netlify/netlify.cue @@ -1,6 +1,9 @@ package netlify -import "dagger.io/dagger" +import ( + "dagger.io/dagger" + "dagger.io/alpine" +) // A Netlify account #Account: { @@ -34,20 +37,13 @@ import "dagger.io/dagger" string #dagger: compute: [ - dagger.#FetchContainer & { - ref: "alpine@sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930" - }, - dagger.#Exec & { - args: ["apk", "add", "-U", "--no-cache", "bash=5.1.0-r0"] - }, - dagger.#Exec & { - args: ["apk", "add", "-U", "--no-cache", "jq=1.6-r1"] - }, - dagger.#Exec & { - args: ["apk", "add", "-U", "--no-cache", "curl=7.74.0-r0"] - }, - dagger.#Exec & { - args: ["apk", "add", "-U", "--no-cache", "yarn=1.22.10-r0"] + dagger.#Load & { + from: alpine.#Image & { + package: bash: "=5.1.0-r0" + package: jq: "=1.6-r1" + package: curl: "=7.74.0-r0" + package: yarn: "=1.22.10-r0" + } }, dagger.#Exec & { args: ["yarn", "global", "add", "netlify-cli@2.47.0"] diff --git a/stdlib/yarn/yarn.cue b/stdlib/yarn/yarn.cue index 2bf51222..bdb47acb 100644 --- a/stdlib/yarn/yarn.cue +++ b/stdlib/yarn/yarn.cue @@ -2,6 +2,7 @@ package yarn import ( "dagger.io/dagger" + "dagger.io/alpine" ) // Yarn Script @@ -20,14 +21,11 @@ import ( env?: [string]: string #dagger: compute: [ - dagger.#FetchContainer & { - ref: "alpine@sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930" - }, - dagger.#Exec & { - args: ["apk", "add", "-U", "--no-cache", "bash=5.1.0-r0"] - }, - dagger.#Exec & { - args: ["apk", "add", "-U", "--no-cache", "yarn=1.22.10-r0"] + dagger.#Load & { + from: alpine.#Image & { + package: bash: "=5.1.0-r0" + package: yarn: "=1.22.10-r0" + } }, dagger.#Exec & { args: [ diff --git a/tests/test.sh b/tests/test.sh index 2a42d807..93788624 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -13,6 +13,13 @@ DAGGER_BINARY_ARGS="${DAGGER_BINARY_ARGS:---log-format json}" read -ra DAGGER_BINARY_ARGS <<< "${DAGGER_BINARY_ARGS:-}" readonly DAGGER_BINARY_ARGS +test::examples() { + local dagger="$1" + + test::one "Examples: simple" --stdout='{"www":{"listing":"simple.cue\n","source":{}}}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute --input-dir www.source="$d"/../examples/simple "$d"/../examples/simple +} + test::compute(){ local dagger="$1" @@ -237,6 +244,8 @@ test::all(){ test::export "$dagger" test::input "$dagger" test::subdir "$dagger" + + test::examples "$dagger" } case "${1:-all}" in