Merge pull request #1404 from talentedmrjones/europa-rename-engine-build-dockerfile
rename engine.#Build to engine.#Dockerfile
This commit is contained in:
commit
589fc6b674
@ -68,16 +68,14 @@ package engine
|
|||||||
config: #ImageConfig
|
config: #ImageConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build a container image using buildkit
|
// Build a container image using a Dockerfile
|
||||||
// FIXME: rename to #Dockerfile to clarify scope
|
#Dockerfile: {
|
||||||
#Build: {
|
$dagger: task: _name: "Dockerfile"
|
||||||
$dagger: task: _name: "Build"
|
|
||||||
|
|
||||||
// Source directory to build
|
// Source directory to build
|
||||||
source: #FS
|
source: #FS
|
||||||
{
|
|
||||||
frontend: "dockerfile"
|
dockerfile: *{
|
||||||
dockerfile: {
|
|
||||||
path: string | *"Dockerfile"
|
path: string | *"Dockerfile"
|
||||||
} | {
|
} | {
|
||||||
contents: string
|
contents: string
|
||||||
@ -90,17 +88,15 @@ package engine
|
|||||||
secret: string | #Secret
|
secret: string | #Secret
|
||||||
}]
|
}]
|
||||||
|
|
||||||
// FIXME: options ported from op.#DockerBuild
|
|
||||||
platforms?: [...string]
|
platforms?: [...string]
|
||||||
target?: string
|
target?: string
|
||||||
buildArg?: [string]: string
|
buildArg?: [string]: string
|
||||||
label?: [string]: string
|
label?: [string]: string
|
||||||
hosts?: [string]: string
|
hosts?: [string]: string
|
||||||
}
|
|
||||||
|
|
||||||
// Root filesystem produced by build
|
// Root filesystem produced
|
||||||
output: #FS
|
output: #FS
|
||||||
|
|
||||||
// Container image config produced by build
|
// Container image config produced
|
||||||
config: #ImageConfig
|
config: #ImageConfig
|
||||||
}
|
}
|
||||||
|
@ -22,27 +22,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Register("Build", func() Task { return &buildTask{} })
|
Register("Dockerfile", func() Task { return &dockerfileTask{} })
|
||||||
}
|
}
|
||||||
|
|
||||||
type buildTask struct {
|
type dockerfileTask struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *buildTask) Run(ctx context.Context, pctx *plancontext.Context, s solver.Solver, v *compiler.Value) (*compiler.Value, error) {
|
func (t *dockerfileTask) Run(ctx context.Context, pctx *plancontext.Context, s solver.Solver, v *compiler.Value) (*compiler.Value, error) {
|
||||||
frontend, err := v.Lookup("frontend").String()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
switch frontend {
|
|
||||||
case "dockerfile":
|
|
||||||
return t.dockerfile(ctx, pctx, s, v)
|
|
||||||
default:
|
|
||||||
return nil, fmt.Errorf("unsupported frontend %q", frontend)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *buildTask) dockerfile(ctx context.Context, pctx *plancontext.Context, s solver.Solver, v *compiler.Value) (*compiler.Value, error) {
|
|
||||||
lg := log.Ctx(ctx)
|
lg := log.Ctx(ctx)
|
||||||
|
|
||||||
// Read auth info
|
// Read auth info
|
||||||
@ -144,7 +130,7 @@ func (t *buildTask) dockerfile(ctx context.Context, pctx *plancontext.Context, s
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *buildTask) dockerBuildOpts(v *compiler.Value, pctx *plancontext.Context) (map[string]string, error) {
|
func (t *dockerfileTask) dockerBuildOpts(v *compiler.Value, pctx *plancontext.Context) (map[string]string, error) {
|
||||||
opts := map[string]string{}
|
opts := map[string]string{}
|
||||||
|
|
||||||
if dockerfilePath := v.Lookup("dockerfile.path"); dockerfilePath.Exists() {
|
if dockerfilePath := v.Lookup("dockerfile.path"); dockerfilePath.Exists() {
|
@ -75,19 +75,18 @@ setup() {
|
|||||||
assert_failure
|
assert_failure
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "task: #Build" {
|
@test "task: #Dockerfile" {
|
||||||
cd "$TESTDIR"/tasks/build
|
cd "$TESTDIR"/tasks/dockerfile
|
||||||
|
|
||||||
"$DAGGER" --europa up ./dockerfile.cue
|
"$DAGGER" --europa up ./dockerfile.cue
|
||||||
"$DAGGER" --europa up ./inlined_dockerfile.cue
|
"$DAGGER" --europa up ./inlined_dockerfile.cue
|
||||||
|
"$DAGGER" --europa up ./inlined_dockerfile_heredoc.cue
|
||||||
"$DAGGER" --europa up ./dockerfile_path.cue
|
"$DAGGER" --europa up ./dockerfile_path.cue
|
||||||
"$DAGGER" --europa up ./build_args.cue
|
"$DAGGER" --europa up ./build_args.cue
|
||||||
"$DAGGER" --europa up ./image_config.cue
|
"$DAGGER" --europa up ./image_config.cue
|
||||||
"$DAGGER" --europa up ./labels.cue
|
"$DAGGER" --europa up ./labels.cue
|
||||||
"$DAGGER" --europa up ./platform.cue
|
"$DAGGER" --europa up ./platform.cue
|
||||||
|
"$DAGGER" --europa up ./build_auth.cue
|
||||||
cd "$TESTDIR"
|
|
||||||
"$DAGGER" --europa up ./tasks/build/build_auth.cue
|
|
||||||
}
|
}
|
||||||
@test "task: #Scratch" {
|
@test "task: #Scratch" {
|
||||||
cd "$TESTDIR"/tasks/scratch
|
cd "$TESTDIR"/tasks/scratch
|
||||||
|
1
tests/tasks/copy/cue.mod/pkg/.gitignore
vendored
1
tests/tasks/copy/cue.mod/pkg/.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
# generated by dagger
|
# generated by dagger
|
||||||
alpha.dagger.io
|
alpha.dagger.io
|
||||||
|
dagger.io
|
||||||
dagger.lock
|
dagger.lock
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
engine.#Plan & {
|
engine.#Plan & {
|
||||||
inputs: directories: testdata: path: "./testdata"
|
inputs: directories: testdata: path: "./testdata"
|
||||||
|
|
||||||
actions: build: engine.#Build & {
|
actions: build: engine.#Dockerfile & {
|
||||||
source: inputs.directories.testdata.contents
|
source: inputs.directories.testdata.contents
|
||||||
dockerfile: contents: """
|
dockerfile: contents: """
|
||||||
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
@ -1,3 +1,5 @@
|
|||||||
# generated by dagger
|
# generated by dagger
|
||||||
alpha.dagger.io
|
alpha.dagger.io
|
||||||
|
dagger.io
|
||||||
dagger.lock
|
dagger.lock
|
||||||
|
universe.dagger.io
|
@ -8,7 +8,7 @@ engine.#Plan & {
|
|||||||
inputs: directories: testdata: path: "./testdata"
|
inputs: directories: testdata: path: "./testdata"
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
build: engine.#Build & {
|
build: engine.#Dockerfile & {
|
||||||
source: inputs.directories.testdata.contents
|
source: inputs.directories.testdata.contents
|
||||||
}
|
}
|
||||||
|
|
@ -8,7 +8,7 @@ engine.#Plan & {
|
|||||||
inputs: directories: testdata: path: "./testdata"
|
inputs: directories: testdata: path: "./testdata"
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
build: engine.#Build & {
|
build: engine.#Dockerfile & {
|
||||||
source: inputs.directories.testdata.contents
|
source: inputs.directories.testdata.contents
|
||||||
dockerfile: path: "./dockerfilepath/Dockerfile.custom"
|
dockerfile: path: "./dockerfilepath/Dockerfile.custom"
|
||||||
}
|
}
|
@ -9,7 +9,7 @@ engine.#Plan & {
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
// FIXME: this doesn't test anything beside not crashing
|
// FIXME: this doesn't test anything beside not crashing
|
||||||
build: engine.#Build & {
|
build: engine.#Dockerfile & {
|
||||||
source: inputs.directories.testdata.contents
|
source: inputs.directories.testdata.contents
|
||||||
dockerfile: contents: """
|
dockerfile: contents: """
|
||||||
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
@ -8,7 +8,7 @@ engine.#Plan & {
|
|||||||
inputs: directories: testdata: path: "./testdata"
|
inputs: directories: testdata: path: "./testdata"
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
build: engine.#Build & {
|
build: engine.#Dockerfile & {
|
||||||
source: inputs.directories.testdata.contents
|
source: inputs.directories.testdata.contents
|
||||||
dockerfile: contents: """
|
dockerfile: contents: """
|
||||||
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
95
tests/tasks/dockerfile/inlined_dockerfile_heredoc.cue
Normal file
95
tests/tasks/dockerfile/inlined_dockerfile_heredoc.cue
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
package testing
|
||||||
|
|
||||||
|
import (
|
||||||
|
"dagger.io/dagger/engine"
|
||||||
|
)
|
||||||
|
|
||||||
|
engine.#Plan & {
|
||||||
|
inputs: directories: testdata: path: "./testdata"
|
||||||
|
|
||||||
|
actions: {
|
||||||
|
build: engine.#Dockerfile & {
|
||||||
|
source: inputs.directories.testdata.contents
|
||||||
|
dockerfile: contents: """
|
||||||
|
# syntax = docker/dockerfile:1.3
|
||||||
|
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
||||||
|
RUN echo foobar > /output
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
|
||||||
|
verify: engine.#Exec & {
|
||||||
|
input: build.output
|
||||||
|
args: ["sh", "-c", "test $(cat /output) = foobar"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestDockerfilePath: #up: [
|
||||||
|
// op.#DockerBuild & {
|
||||||
|
// context: TestData
|
||||||
|
// dockerfilePath: "./dockerfilepath/Dockerfile.custom"
|
||||||
|
// },
|
||||||
|
// op.#Exec & {
|
||||||
|
// args: ["sh", "-c", "test $(cat /test) = dockerfilePath"]
|
||||||
|
// },
|
||||||
|
// ]
|
||||||
|
|
||||||
|
// TestBuildArgs: #up: [
|
||||||
|
// op.#DockerBuild & {
|
||||||
|
// dockerfile: """
|
||||||
|
// FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
||||||
|
// ARG TEST=foo
|
||||||
|
// RUN test "${TEST}" = "bar"
|
||||||
|
// """
|
||||||
|
// buildArg: TEST: "bar"
|
||||||
|
// },
|
||||||
|
// ]
|
||||||
|
|
||||||
|
// // FIXME: this doesn't test anything beside not crashing
|
||||||
|
// TestBuildLabels: #up: [
|
||||||
|
// op.#DockerBuild & {
|
||||||
|
// dockerfile: """
|
||||||
|
// FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
||||||
|
// """
|
||||||
|
// label: FOO: "bar"
|
||||||
|
// },
|
||||||
|
// ]
|
||||||
|
|
||||||
|
// // FIXME: this doesn't test anything beside not crashing
|
||||||
|
// TestBuildPlatform: #up: [
|
||||||
|
// op.#DockerBuild & {
|
||||||
|
// dockerfile: """
|
||||||
|
// FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
||||||
|
// """
|
||||||
|
// platforms: ["linux/amd64"]
|
||||||
|
// },
|
||||||
|
// ]
|
||||||
|
|
||||||
|
// TestImageMetadata: #up: [
|
||||||
|
// op.#DockerBuild & {
|
||||||
|
// dockerfile: """
|
||||||
|
// FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
||||||
|
// ENV CHECK foobar
|
||||||
|
// ENV DOUBLECHECK test
|
||||||
|
// """
|
||||||
|
// },
|
||||||
|
// op.#Exec & {
|
||||||
|
// args: ["sh", "-c", #"""
|
||||||
|
// env
|
||||||
|
// test "$CHECK" = "foobar"
|
||||||
|
// """#]
|
||||||
|
// },
|
||||||
|
// ]
|
||||||
|
|
||||||
|
// // Make sure the metadata is carried over with a `Load`
|
||||||
|
// TestImageMetadataIndirect: #up: [
|
||||||
|
// op.#Load & {
|
||||||
|
// from: TestImageMetadata
|
||||||
|
// },
|
||||||
|
// op.#Exec & {
|
||||||
|
// args: ["sh", "-c", #"""
|
||||||
|
// env
|
||||||
|
// test "$DOUBLECHECK" = "test"
|
||||||
|
// """#]
|
||||||
|
// },
|
||||||
|
// ]
|
@ -9,7 +9,7 @@ engine.#Plan & {
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
// FIXME: this doesn't test anything beside not crashing
|
// FIXME: this doesn't test anything beside not crashing
|
||||||
build: engine.#Build & {
|
build: engine.#Dockerfile & {
|
||||||
source: inputs.directories.testdata.contents
|
source: inputs.directories.testdata.contents
|
||||||
dockerfile: contents: """
|
dockerfile: contents: """
|
||||||
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
@ -9,7 +9,7 @@ engine.#Plan & {
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
// FIXME: this doesn't test anything beside not crashing
|
// FIXME: this doesn't test anything beside not crashing
|
||||||
build: engine.#Build & {
|
build: engine.#Dockerfile & {
|
||||||
source: inputs.directories.testdata.contents
|
source: inputs.directories.testdata.contents
|
||||||
dockerfile: contents: """
|
dockerfile: contents: """
|
||||||
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
1
tests/tasks/exec/cue.mod/pkg/.gitignore
vendored
1
tests/tasks/exec/cue.mod/pkg/.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
# generated by dagger
|
# generated by dagger
|
||||||
alpha.dagger.io
|
alpha.dagger.io
|
||||||
|
dagger.io
|
||||||
dagger.lock
|
dagger.lock
|
||||||
|
1
tests/tasks/mkdir/cue.mod/pkg/.gitignore
vendored
1
tests/tasks/mkdir/cue.mod/pkg/.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
# generated by dagger
|
# generated by dagger
|
||||||
alpha.dagger.io
|
alpha.dagger.io
|
||||||
|
dagger.io
|
||||||
dagger.lock
|
dagger.lock
|
||||||
|
1
tests/tasks/pull/cue.mod/pkg/.gitignore
vendored
1
tests/tasks/pull/cue.mod/pkg/.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
# generated by dagger
|
# generated by dagger
|
||||||
alpha.dagger.io
|
alpha.dagger.io
|
||||||
|
dagger.io
|
||||||
dagger.lock
|
dagger.lock
|
||||||
|
1
tests/tasks/readfile/cue.mod/pkg/.gitignore
vendored
1
tests/tasks/readfile/cue.mod/pkg/.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
# generated by dagger
|
# generated by dagger
|
||||||
alpha.dagger.io
|
alpha.dagger.io
|
||||||
|
dagger.io
|
||||||
dagger.lock
|
dagger.lock
|
||||||
|
1
tests/tasks/scratch/cue.mod/pkg/.gitignore
vendored
1
tests/tasks/scratch/cue.mod/pkg/.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
# generated by dagger
|
# generated by dagger
|
||||||
alpha.dagger.io
|
alpha.dagger.io
|
||||||
|
dagger.io
|
||||||
dagger.lock
|
dagger.lock
|
||||||
|
1
tests/tasks/writefile/cue.mod/pkg/.gitignore
vendored
1
tests/tasks/writefile/cue.mod/pkg/.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
# generated by dagger
|
# generated by dagger
|
||||||
alpha.dagger.io
|
alpha.dagger.io
|
||||||
|
dagger.io
|
||||||
dagger.lock
|
dagger.lock
|
||||||
|
Reference in New Issue
Block a user