diff --git a/pkg/universe.dagger.io/cue.mod/pkg/.gitignore b/pkg/universe.dagger.io/cue.mod/pkg/.gitignore new file mode 100644 index 00000000..331f139d --- /dev/null +++ b/pkg/universe.dagger.io/cue.mod/pkg/.gitignore @@ -0,0 +1,5 @@ +# generated by dagger +dagger.lock +alpha.dagger.io +dagger.io +universe.dagger.io \ No newline at end of file diff --git a/pkg/universe.dagger.io/docker/build.cue b/pkg/universe.dagger.io/docker/build.cue index 2eaccf76..162315af 100644 --- a/pkg/universe.dagger.io/docker/build.cue +++ b/pkg/universe.dagger.io/docker/build.cue @@ -61,15 +61,7 @@ import ( // Build step that executes a Dockerfile #Dockerfile: { - // Source image - input?: #Image - - // FIXME cannot replace with _source: *engine.#Scratch | input.rootfs - // Got error "$dagger" not found - _source: input.rootfs - if input == _|_ { - _source: engine.#Scratch - } + source: dagger.#FS // Dockerfile definition or path into source dockerfile: *{ @@ -91,12 +83,9 @@ import ( label: [string]: string hosts: [string]: string - _build: engine.#Dockerfile & { - source: _source - "auth": [ for target, creds in auth { - "target": target - creds - }] + _build: dagger.#Dockerfile & { + "source": source + "auth": auth "dockerfile": dockerfile "platforms": platforms if target != _|_ { diff --git a/pkg/universe.dagger.io/docker/test/build-dockerfile-input.cue b/pkg/universe.dagger.io/docker/test/build-dockerfile-input.cue deleted file mode 100644 index d8cf7b4e..00000000 --- a/pkg/universe.dagger.io/docker/test/build-dockerfile-input.cue +++ /dev/null @@ -1,34 +0,0 @@ -package test - -import ( - "dagger.io/dagger" - "dagger.io/dagger/engine" - "universe.dagger.io/docker" -) - -dagger.#Plan & { - inputs: directories: testdata: path: "./testdata" - - actions: { - image: docker.#Build & { - steps: [ - docker.#Dockerfile & { - input: rootfs: inputs.directories.testdata.contents - }, - docker.#Run & { - always: true - script: """ - hello >> /test.txt - """ - }, - ] - } - - verify: engine.#ReadFile & { - input: image.output.rootfs - path: "/test.txt" - } & { - contents: "hello world" - } - } -} diff --git a/pkg/universe.dagger.io/docker/test/build-dockerfile.cue b/pkg/universe.dagger.io/docker/test/build-dockerfile.cue deleted file mode 100644 index eda717cb..00000000 --- a/pkg/universe.dagger.io/docker/test/build-dockerfile.cue +++ /dev/null @@ -1,37 +0,0 @@ -package test - -import ( - "dagger.io/dagger" - "dagger.io/dagger/engine" - "universe.dagger.io/docker" -) - -dagger.#Plan & { - actions: { - build: docker.#Build & { - steps: [ - docker.#Dockerfile & { - dockerfile: contents: """ - FROM alpine:3.15 - - RUN echo -n hello world >> /test.txt - """ - }, - docker.#Run & { - script: """ - # Verify that docker.#Dockerfile correctly connect output - # into other steps - grep -q "hello world" /test.txt - """ - }, - ] - } - - verify: engine.#ReadFile & { - input: build.output.rootfs - path: "/test.txt" - } & { - contents: "hello world" - } - } -} diff --git a/pkg/universe.dagger.io/docker/test/dockerfile.cue b/pkg/universe.dagger.io/docker/test/dockerfile.cue new file mode 100644 index 00000000..73982fb3 --- /dev/null +++ b/pkg/universe.dagger.io/docker/test/dockerfile.cue @@ -0,0 +1,69 @@ +package docker + +import ( + "dagger.io/dagger" + "universe.dagger.io/docker" +) + +dagger.#Plan & { + inputs: directories: testdata: path: "./testdata" + + actions: tests: dockerfile: { + simple: { + build: docker.#Build & { + steps: [ + docker.#Dockerfile & { + source: dagger.#Scratch + dockerfile: contents: """ + FROM alpine:3.15 + + RUN echo -n hello world >> /test.txt + """ + }, + docker.#Run & { + command: { + name: "/bin/sh" + args: ["-c", """ + # Verify that docker.#Dockerfile correctly connect output + # into other steps + grep -q "hello world" /test.txt + """] + } + }, + ] + } + + verify: dagger.#ReadFile & { + input: build.output.rootfs + path: "/test.txt" + } & { + contents: "hello world" + } + } + + withInput: { + build: docker.#Build & { + steps: [ + docker.#Dockerfile & { + source: inputs.directories.testdata.contents + }, + docker.#Run & { + command: { + name: "/bin/sh" + args: ["-c", """ + hello >> /test.txt + """] + } + }, + ] + } + + verify: dagger.#ReadFile & { + input: build.output.rootfs + path: "/test.txt" + } & { + contents: "hello world" + } + } + } +}