Merge pull request #971 from VazeeKevin/tasks/improve-stdlib-docker
stdlib/docker: update #Build to incorporate image from Dockerfile
This commit is contained in:
commit
12e457e9e9
@ -12,13 +12,14 @@ import "alpha.dagger.io/docker"
|
||||
|
||||
## docker.#Build
|
||||
|
||||
Build a Docker image from source, using included Dockerfile
|
||||
Build a Docker image from source
|
||||
|
||||
### docker.#Build Inputs
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------------- |:-------------: |:-------------: |
|
||||
|*source* | `dagger.#Artifact` |- |
|
||||
| Name | Type | Description |
|
||||
| ------------- |:-------------: |:-------------: |
|
||||
|*source* | `dagger.#Artifact` |Build context |
|
||||
|*dockerfile* | `*null \| string` |Dockerfile passed as a string |
|
||||
|
||||
### docker.#Build Outputs
|
||||
|
||||
@ -39,21 +40,6 @@ A container image that can run any docker command
|
||||
|
||||
_No output._
|
||||
|
||||
## docker.#ImageFromDockerfile
|
||||
|
||||
Build a Docker image from the provided Dockerfile contents
|
||||
|
||||
### docker.#ImageFromDockerfile Inputs
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------------- |:-------------: |:-------------: |
|
||||
|*dockerfile* | `string` |Dockerfile passed as a string |
|
||||
|*context* | `dagger.#Artifact` |Build context |
|
||||
|
||||
### docker.#ImageFromDockerfile Outputs
|
||||
|
||||
_No output._
|
||||
|
||||
## docker.#Pull
|
||||
|
||||
Pull a docker container
|
||||
|
@ -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
|
||||
},
|
||||
]
|
||||
}
|
||||
|
@ -28,15 +28,43 @@ TestBuild: {
|
||||
]
|
||||
}
|
||||
|
||||
TestSourceImageFromDockerfile: dagger.#Artifact @dagger(input)
|
||||
|
||||
TestImageFromDockerfile: {
|
||||
image: #ImageFromDockerfile & {
|
||||
TestBuildWithArgs: {
|
||||
image: #Build & {
|
||||
dockerfile: """
|
||||
FROM alpine
|
||||
COPY test.txt /test.txt
|
||||
ARG TEST
|
||||
ENV TEST=$TEST
|
||||
RUN echo "$TEST" > /test.txt
|
||||
"""
|
||||
context: TestSourceImageFromDockerfile
|
||||
source: ""
|
||||
args: TEST: "test"
|
||||
}
|
||||
|
||||
verify: #up: [
|
||||
op.#Load & {
|
||||
from: image
|
||||
},
|
||||
|
||||
op.#Exec & {
|
||||
always: true
|
||||
args: [
|
||||
"sh", "-c", """
|
||||
grep -q "test" /test.txt
|
||||
""",
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
TestSourceImageFromDockerfile: dagger.#Artifact @dagger(input)
|
||||
|
||||
TestImageFromDockerfile: {
|
||||
image: #Build & {
|
||||
dockerfile: """
|
||||
FROM alpine
|
||||
COPY test.txt /test.txt
|
||||
"""
|
||||
source: TestSourceImageFromDockerfile
|
||||
}
|
||||
|
||||
verify: #up: [
|
||||
|
@ -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 & {
|
||||
|
@ -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: ""
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 & {
|
||||
|
Reference in New Issue
Block a user