Merge pull request #1468 from aluzzardi/nested-docker-build

docker.#Build: support for nested builds
This commit is contained in:
Andrea Luzzardi 2022-01-20 16:09:30 -08:00 committed by GitHub
commit 7cd17c39bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 78 additions and 81 deletions

View File

@ -16,7 +16,12 @@ import (
"\(idx)": step & {
// connect input to previous output
if idx > 0 {
input: _dag["\(idx-1)"].output
// FIXME: the intermediary `output` is needed because of a possible CUE bug.
// `._dag."0".output: 1 errors in empty disjunction::`
// See: https://github.com/cue-lang/cue/issues/1446
// input: _dag["\(idx-1)"].output
_output: _dag["\(idx-1)"].output
input: _output
}
}
}

View File

@ -1,15 +0,0 @@
package docker
cmd: #Command & {
script: "echo hello world"
exec: {
name: "/bin/bash"
flags: {
"-c": script
"--noprofile": true
"--norc": true
"-e": true
"-o": "pipefail"
}
}
}

View File

@ -1,65 +0,0 @@
package docker
import (
"dagger.io/dagger"
"universe.dagger.io/nginx"
)
tests: {
"set config manually": build: #Build & {
steps: [{
output: #Image & {
config: user: "foo"
}
}]
}
// - import nginx base
// - copy app directory into /usr/share/nginx/html
"build static web server": {
source: dagger.#FS
build: #Build & {
steps: [
nginx.#Build & {
flavor: "alpine"
},
{
// Custom step to watermark the image
input: _
output: input & {
config: user: "42"
}
},
#Copy & {
contents: source
dest: "/usr/share/nginx/html"
},
]
}
image: build.output
// Assert:
image: config: user: "42"
}
"Run multiple commands": {
build: #Build & {
steps: [
#Pull & {
source: "alpine"
},
#Run & {
script: "echo A > /A.txt"
},
#Run & {
script: "echo B > /B.txt"
},
#Run & {
script: "echo C > /C.txt"
},
]
}
result: build.output
}
}

View File

@ -0,0 +1,13 @@
setup() {
load '../../bats_helpers'
common_setup
}
@test "docker.#Build" {
dagger up ./nested-build-test.cue
# FIXME: this is currently broken
run dagger up ./multi-nested-build-test.cue
assert_failure
}

View File

@ -0,0 +1,33 @@
package docker
import (
"dagger.io/dagger"
"universe.dagger.io/docker"
)
dagger.#Plan & {
actions: build: docker.#Build & {
steps: [
docker.#Build & {
steps: [
docker.#Build & {
steps: [
docker.#Pull & {
source: "alpine"
},
docker.#Run & {
cmd: name: "ls"
},
]
},
docker.#Run & {
cmd: name: "ls"
},
]
},
docker.#Run & {
cmd: name: "ls"
},
]
}
}

View File

@ -0,0 +1,26 @@
package docker
import (
"dagger.io/dagger"
"universe.dagger.io/docker"
)
dagger.#Plan & {
actions: build: docker.#Build & {
steps: [
docker.#Build & {
steps: [
docker.#Pull & {
source: "alpine"
},
docker.#Run & {
cmd: name: "ls"
},
]
},
docker.#Run & {
cmd: name: "ls"
},
]
}
}