This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
dagger/pkg/universe.dagger.io/docker/build.cue
Helder Correia 3956b8b59b
Fix docker.#Run compatibility with docker.#Build
Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com>
2022-01-15 20:01:06 -01:00

77 lines
1.2 KiB
CUE

package docker
import (
"dagger.io/dagger"
"dagger.io/dagger/engine"
)
// Modular build API for Docker containers
#Build: {
steps: [#Step, ...#Step]
output: #Image
// Generate build DAG from linerar steps
_dag: {
for idx, step in steps {
"\(idx)": step & {
// connect input to previous output
if idx > 0 {
input: _dag["\(idx-1)"].output
}
}
}
}
if len(_dag) > 0 {
output: _dag["\(len(_dag)-1)"].output
}
}
// A build step is anything that produces a docker image
#Step: {
input?: #Image
output: #Image
...
}
// Build step that copies files into the container image
#Copy: {
input: #Image
contents: dagger.#FS
source: string | *"/"
dest: string | *"/"
// Execute copy operation
_copy: engine.#Copy & {
"input": input.rootfs
"source": {
root: contents
path: source
}
"dest": dest
}
output: #Image & {
config: input.config
rootfs: _copy.output
}
}
// Build step that executes a Dockerfile
#Dockerfile: {
// Source directory
source: dagger.#FS
// FIXME: not yet implemented
*{
// Look for Dockerfile in source at default path
path: "Dockerfile"
} | {
// Look for Dockerfile in source at a custom path
path: string
} | {
// Custom dockerfile contents
contents: string
}
}