2021-02-19 09:09:53 +01:00
|
|
|
package test
|
|
|
|
|
2021-04-01 03:34:23 +02:00
|
|
|
import (
|
|
|
|
"dagger.io/dagger"
|
2021-04-06 02:27:51 +02:00
|
|
|
"dagger.io/dagger/op"
|
2021-04-01 03:34:23 +02:00
|
|
|
)
|
2021-02-19 09:09:53 +01:00
|
|
|
|
|
|
|
// Set to `--input-dir=./tests/dockerbuild/testdata`
|
2021-03-13 07:29:37 +01:00
|
|
|
TestData: dagger.#Artifact
|
2021-02-19 09:09:53 +01:00
|
|
|
|
2021-04-03 00:00:30 +02:00
|
|
|
TestInlinedDockerfile: #up: [
|
2021-04-06 02:27:51 +02:00
|
|
|
op.#DockerBuild & {
|
2021-02-19 09:09:53 +01:00
|
|
|
dockerfile: """
|
|
|
|
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
|
|
|
RUN echo hello world
|
|
|
|
"""
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
2021-04-03 00:00:30 +02:00
|
|
|
TestOpChaining: #up: [
|
2021-04-06 02:27:51 +02:00
|
|
|
op.#DockerBuild & {
|
2021-02-19 09:09:53 +01:00
|
|
|
dockerfile: """
|
|
|
|
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
|
|
|
RUN echo foobar > /output
|
|
|
|
"""
|
|
|
|
},
|
2021-04-06 02:27:51 +02:00
|
|
|
op.#Exec & {
|
2021-02-19 09:09:53 +01:00
|
|
|
args: ["sh", "-c", "test $(cat /output) = foobar"]
|
2021-03-13 03:12:58 +01:00
|
|
|
},
|
2021-02-19 09:09:53 +01:00
|
|
|
]
|
|
|
|
|
2021-04-03 00:00:30 +02:00
|
|
|
TestBuildContext: #up: [
|
2021-04-06 02:27:51 +02:00
|
|
|
op.#DockerBuild & {
|
2021-02-19 09:09:53 +01:00
|
|
|
context: TestData
|
|
|
|
},
|
2021-04-06 02:27:51 +02:00
|
|
|
op.#Exec & {
|
2021-02-19 09:09:53 +01:00
|
|
|
args: ["sh", "-c", "test $(cat /dir/foo) = foobar"]
|
2021-03-13 03:12:58 +01:00
|
|
|
},
|
2021-02-19 09:09:53 +01:00
|
|
|
]
|
|
|
|
|
2021-04-03 00:00:30 +02:00
|
|
|
TestBuildContextAndDockerfile: #up: [
|
2021-04-06 02:27:51 +02:00
|
|
|
op.#DockerBuild & {
|
2021-02-19 09:09:53 +01:00
|
|
|
context: TestData
|
|
|
|
dockerfile: """
|
|
|
|
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
|
|
|
COPY foo /override
|
|
|
|
"""
|
|
|
|
},
|
2021-04-06 02:27:51 +02:00
|
|
|
op.#Exec & {
|
2021-02-19 09:09:53 +01:00
|
|
|
args: ["sh", "-c", "test $(cat /override) = foobar"]
|
2021-03-13 03:12:58 +01:00
|
|
|
},
|
2021-02-19 09:09:53 +01:00
|
|
|
]
|
|
|
|
|
2021-04-03 00:00:30 +02:00
|
|
|
TestDockerfilePath: #up: [
|
2021-04-06 02:27:51 +02:00
|
|
|
op.#DockerBuild & {
|
2021-03-13 03:12:58 +01:00
|
|
|
context: TestData
|
2021-02-19 09:09:53 +01:00
|
|
|
dockerfilePath: "./dockerfilepath/Dockerfile.custom"
|
|
|
|
},
|
2021-04-06 02:27:51 +02:00
|
|
|
op.#Exec & {
|
2021-02-19 09:09:53 +01:00
|
|
|
args: ["sh", "-c", "test $(cat /test) = dockerfilePath"]
|
2021-03-13 03:12:58 +01:00
|
|
|
},
|
2021-02-19 09:09:53 +01:00
|
|
|
]
|
|
|
|
|
2021-04-03 00:00:30 +02:00
|
|
|
TestBuildArgs: #up: [
|
2021-04-06 02:27:51 +02:00
|
|
|
op.#DockerBuild & {
|
2021-02-19 09:09:53 +01:00
|
|
|
dockerfile: """
|
|
|
|
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
|
|
|
ARG TEST=foo
|
|
|
|
RUN test "${TEST}" = "bar"
|
|
|
|
"""
|
|
|
|
buildArg: TEST: "bar"
|
2021-03-13 03:12:58 +01:00
|
|
|
},
|
2021-02-19 09:09:53 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
// FIXME: this doesn't test anything beside not crashing
|
2021-04-03 00:00:30 +02:00
|
|
|
TestBuildLabels: #up: [
|
2021-04-06 02:27:51 +02:00
|
|
|
op.#DockerBuild & {
|
2021-02-19 09:09:53 +01:00
|
|
|
dockerfile: """
|
|
|
|
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
|
|
|
"""
|
|
|
|
label: FOO: "bar"
|
2021-03-13 03:12:58 +01:00
|
|
|
},
|
2021-02-19 09:09:53 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
// FIXME: this doesn't test anything beside not crashing
|
2021-04-03 00:00:30 +02:00
|
|
|
TestBuildPlatform: #up: [
|
2021-04-06 02:27:51 +02:00
|
|
|
op.#DockerBuild & {
|
2021-02-19 09:09:53 +01:00
|
|
|
dockerfile: """
|
|
|
|
FROM alpine:latest@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
|
|
|
|
"""
|
|
|
|
platforms: ["linux/amd64"]
|
2021-03-13 03:12:58 +01:00
|
|
|
},
|
2021-02-19 09:09:53 +01:00
|
|
|
]
|