diff --git a/examples/simple/cue.mod/pkg/dagger.cloud/alpine/alpine.cue b/examples/simple/cue.mod/pkg/dagger.cloud/alpine/alpine.cue deleted file mode 100644 index 6544e81f..00000000 --- a/examples/simple/cue.mod/pkg/dagger.cloud/alpine/alpine.cue +++ /dev/null @@ -1,50 +0,0 @@ -package alpine - -// Default version pinned to digest. Manually updated. -let defaultDigest="sha256:3c7497bf0c7af93428242d6176e8f7905f2201d8fc5861f45be7a346b5f23436" - -ref: string - -// Match a combination of inputs 'version' and 'digest': -*{ - // no version, no digest: - ref: "index.docker.io/alpine@\(defaultDigest)" -} | { - // version, no digest - version: string - ref: "alpine:\(version)" -} | { - // digest, no version - digest: string - ref: "alpine@\(digest)" -} | { - // version and digest - version: string - digest: string - ref: "alpine:\(version)@\(digest)" -} - -// Packages to install -package: [string]: true | false | string - -#dagger: compute: [ - { - do: "fetch-container" - "ref": ref - }, - for pkg, info in package { - if (info & true) != _|_ { - do: "exec" - args: ["apk", "add", "-U", "--no-cache", pkg] - // https://github.com/blocklayerhq/dagger/issues/6 - mount: foo: {} - } - if (info & string) != _|_ { - do: "exec" - args: ["apk", "add", "-U", "--no-cache", "\(pkg)\(info)"] - // https://github.com/blocklayerhq/dagger/issues/6 - mount: foo: {} - } - }, -] - diff --git a/examples/simple/cue.mod/pkg/dagger.cloud/dagger/dagger.cue b/examples/simple/cue.mod/pkg/dagger.cloud/dagger/dagger.cue index 407d9127..6d315bb0 100644 --- a/examples/simple/cue.mod/pkg/dagger.cloud/dagger/dagger.cue +++ b/examples/simple/cue.mod/pkg/dagger.cloud/dagger/dagger.cue @@ -51,7 +51,9 @@ package dagger // Any component can be referenced as a directory, since // every dagger script outputs a filesystem state (aka a directory) -#Dir: #Component +#Dir: #Component & { + #dagger: compute: _ +} #Script: [...#Op] @@ -67,8 +69,8 @@ package dagger } #Local: { - do: "local" - dir: string + do: "local" + dir: string include: [...string] | *[] } @@ -92,11 +94,11 @@ package dagger #MountCache: "cache" #MountComponent: { from: #Component - path: string | *"/" + path: string | *"/" } #MountScript: { from: #Script - path: string | *"/" + path: string | *"/" } #FetchContainer: { diff --git a/examples/simple/simple.cue b/examples/simple/simple.cue index e096eb13..728a0ed3 100644 --- a/examples/simple/simple.cue +++ b/examples/simple/simple.cue @@ -3,23 +3,33 @@ package acme import ( - "dagger.cloud/alpine" "dagger.cloud/dagger" ) -let base=alpine & { - package: { - bash: ">3.0" - rsync: true - } +let alpine={ + digest: "sha256:3c7497bf0c7af93428242d6176e8f7905f2201d8fc5861f45be7a346b5f23436" + package: [string]: true | false | string + #dagger: compute: [ + { + do: "fetch-container" + ref: "index.docker.io@\(digest)" + }, + for pkg, info in package { + if (info & true) != _|_ { + do: "exec" + args: ["apk", "add", "-U", "--no-cache", pkg] + } + if (info & string) != _|_ { + do: "exec" + args: ["apk", "add", "-U", "--no-cache", "\(pkg)\(info)"] + } + }, + ] } www: { - source: { - // Make this undefined on purpose to require an input directory. - #dagger: compute: _ - } + source: dagger.#Dir // List the contents of the source directory listing: { @@ -27,7 +37,7 @@ www: { #dagger: compute: [ dagger.#Load & { - from: base + from: alpine }, dagger.#Exec & { args: ["sh", "-c", "ls /src > /tmp/out"] @@ -47,7 +57,10 @@ www: { string #dagger: compute: [ - dagger.#Load & { from: base }, + { + do: "load" + from: alpine + }, dagger.#Exec & { args: ["sh", "-c", "echo -n 'https://\(host)/foo' > /tmp/out"] },