Update Docker #Build to incorporate image from Dockerfile

Signed-off-by: Kevin Poirot <kevin@vazee.fr>
This commit is contained in:
Kevin Poirot
2021-09-14 09:54:09 +02:00
parent 4d45e269e0
commit 3e14920062
6 changed files with 21 additions and 45 deletions

View File

@@ -6,15 +6,22 @@ import (
"alpha.dagger.io/dagger/op"
)
// Build a Docker image from source, using included Dockerfile
// Build a Docker image from source
#Build: {
// Build context
source: dagger.#Input & {dagger.#Artifact}
// Dockerfile passed as a string
dockerfile: dagger.#Input & {*null | string}
args?: [string]: string
#up: [
op.#DockerBuild & {
context: source
if dockerfile != null {
"dockerfile": dockerfile
}
if args != _|_ {
buildArg: args
}
@@ -150,20 +157,3 @@ import (
}
}
}
// Build a Docker image from the provided Dockerfile contents
// FIXME: incorporate into #Build
#ImageFromDockerfile: {
// Dockerfile passed as a string
dockerfile: dagger.#Input & {string}
// Build context
context: dagger.#Input & {dagger.#Artifact}
#up: [
op.#DockerBuild & {
"context": context
"dockerfile": dockerfile
},
]
}

View File

@@ -31,12 +31,12 @@ TestBuild: {
TestSourceImageFromDockerfile: dagger.#Artifact @dagger(input)
TestImageFromDockerfile: {
image: #ImageFromDockerfile & {
image: #Build & {
dockerfile: """
FROM alpine
COPY test.txt /test.txt
"""
context: TestSourceImageFromDockerfile
source: TestSourceImageFromDockerfile
}
verify: #up: [

View File

@@ -17,12 +17,12 @@ TestPush: {
target: "daggerio/ci-test:\(tag.out)"
image: #ImageFromDockerfile & {
image: #Build & {
dockerfile: """
FROM alpine
RUN echo "test" > /test.txt
"""
context: ""
source: ""
}
push: #Push & {

View File

@@ -18,12 +18,12 @@ TestResources: {
// Seed is used to force buildkit execution and not simply use a previous generated string.
suffix: random.#String & {seed: "docker multi registry"}
image: #ImageFromDockerfile & {
image: #Build & {
dockerfile: """
FROM alpine
RUN echo "test" > /test.txt
"""
context: ""
source: ""
}
}

View File

@@ -17,12 +17,12 @@ TestPush: {
target: "daggerio/ci-test:\(tag.out)"
image: #ImageFromDockerfile & {
image: #Build & {
dockerfile: """
FROM alpine
RUN echo "test" > /test.txt
"""
context: ""
source: ""
}
push: #Push & {