Europa: cleanup docker.#Build

Signed-off-by: Solomon Hykes <solomon@dagger.io>
This commit is contained in:
Solomon Hykes 2022-01-07 05:04:59 +00:00 committed by Solomon Hykes
parent 458d04819d
commit 25d1656329
2 changed files with 57 additions and 108 deletions

View File

@ -13,45 +13,11 @@ import (
// Generate build DAG from linerar steps // Generate build DAG from linerar steps
dag: { dag: {
for idx, step in steps { for idx, step in steps {
///// FIXME: this section is broken and in the middle of debug + rewrite "\(idx)": step & {
//// // 1. image -> input // connect input to previous output
//// if (step.input == _|_) && ((step.image & #Image) != _|_) {
//// input: image
//// }
//// // 2.
//// if ((step.output & docker.#Image) == _|_) && ((step.output.rootfs & dagger.#FS) != _|_) {
////
//// }
//// // As a special case, wrap #Run into a valid step
//// if step.run != _|_ {
//// "\(idx)": {
//// input: _
//// run: step & {
//// image: input
//// output: rootfs: _
//// }
//// output: {
//// config: input.config
//// rootfs: run.output.rootfs
//// }
//// }
//// }
//// // Otherwise, just use the step as is
//// if step.run == _|_ {
//// "\(idx)": {
//// run: false
//// step
//// }
//// }
"\(idx)": step
// Either way, connect input to previous output
if idx > 0 { if idx > 0 {
"\(idx)": input: dag["\(idx-1)"].output input: dag["\(idx-1)"].output
}
} }
} }
} }

View File

@ -5,27 +5,18 @@ import (
"universe.dagger.io/nginx" "universe.dagger.io/nginx"
) )
build0: #Build & { tests: {
steps: [ "set config manually": build: #Build & {
{ steps: [{
output: #Image & { output: #Image & {
config: user: "foo" config: user: "foo"
} }
}, }]
] }
}
// Inventory of real-world build use cases // - import nginx base
// // - copy app directory into /usr/share/nginx/html
// 1. Build netlify image "build static web server": {
// - import alpine base
// - execute 'yarn add netlify'
// 2. Build todoapp dev image
// - import nginx base
// - copy app directory into /usr/share/nginx/html
build2: {
source: dagger.#FS source: dagger.#FS
build: #Build & { build: #Build & {
@ -46,21 +37,13 @@ build2: {
}, },
] ]
} }
img: build.output
image: build.output
// Assert: // Assert:
img: config: user: "42" image: config: user: "42"
} }
// 3. Build alpine base image "Run multiple commands": {
// - pull from docker hub
// - execute 'apk add' once per package
// 4. Build app from dockerfile
// 5. execute several commands in a row
build3: {
build: #Build & { build: #Build & {
steps: [ steps: [
#Pull & { #Pull & {
@ -77,6 +60,6 @@ build3: {
}, },
] ]
} }
result: build.output result: build.output
}
} }