diff --git a/.dagger/env/dev/main.cue b/.dagger/env/dev/main.cue new file mode 100644 index 00000000..90058f72 --- /dev/null +++ b/.dagger/env/dev/main.cue @@ -0,0 +1,86 @@ +// A dagger workflow to develop dagger +package main + +import ( + "dagger.io/dagger" + "dagger.io/dagger/op" + "dagger.io/alpine" + "dagger.io/docker" +) + +// Dagger source code +source: dagger.#Artifact + +// Build the dagger binaries +build: { + testLogs: { + string + #up: [ + op.#Load & { + from: ctr + }, + op.#Exec & { + args: ["ls", "-l", "/"] + }, + op.#Export & { + source: "/test.log" + format: "string" + } + ] + } + + ctr: docker.#Container & { + image: docker.#ImageFromRegistry & { + ref: "docker.io/golang:1.16-alpine" + } + + setup: [ + "apk add --no-cache file", + ] + + command: """ + go test -v ./... > /test.log + go build -o /binaries/ ./cmd/... > /build.log + """ + + volume: { + daggerSource: { + from: source + dest: "/src" + } + goCache: { + type: "cache" + dest: "/root/.cache/gocache" + } + } + + // Add go to search path (FIXME: should be inherited from image metadata) + shell: search: "/usr/local/go/bin": true + + env: { + GOMODCACHE: volume.goCache.dest + CGO_ENABLED: "0" + } + + dir: "/src" + } + + binaries: docker.#Container & { + image: ctr + outputDir: "/binaries" + } +} + + +// Execute `dagger help` +usage: docker.#Container & { + image: alpine.#Image + + command: "dagger help" + + volume: binaries: { + from: build.binaries + dest: "/usr/local/dagger/bin/" + } + shell: search: "/usr/local/dagger/bin": true +} diff --git a/dev.cue b/dev.cue deleted file mode 100644 index 24435677..00000000 --- a/dev.cue +++ /dev/null @@ -1,59 +0,0 @@ -package main - -import ( - "dagger.io/dagger" - "dagger.io/alpine" - "dagger.io/docker" -) - -// Dagger source code -source: dagger.#Artifact - -// Build the dagger binaries -build: docker.#Container & { - image: docker.#ImageFromRef & {ref: "docker.io/golang:1.16-alpine"} - - setup: [ - "apk add --no-cache file", - ] - - command: """ - go test -v ./... - go build -o /binaries/ ./cmd/... - """ - - volume: { - daggerSource: { - from: source - dest: "/src" - } - goCache: { - type: "cache" - dest: "/root/.cache/gocache" - } - } - - // Add go to search path (FIXME: should be inherited from image metadata) - shell: search: "/usr/local/go/bin": true - - env: { - GOMODCACHE: volume.goCache.dest - CGO_ENABLED: "0" - } - - dir: "/src" - outputDir: "/binaries" -} - -// Execute `dagger help` -usage: docker.#Container & { - image: alpine.#Image - - command: "dagger help" - - volume: binaries: { - from: build - dest: "/usr/local/dagger/bin/" - } - shell: search: "/usr/local/dagger/bin": true -} diff --git a/examples/dagger-dev/dev.cue b/examples/dagger-dev/dev.cue deleted file mode 120000 index dd388aaf..00000000 --- a/examples/dagger-dev/dev.cue +++ /dev/null @@ -1 +0,0 @@ -../../dev.cue \ No newline at end of file