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/stdlib/docker/docker.cue

170 lines
2.7 KiB
CUE
Raw Normal View History

// Docker container operations
package docker
import (
"alpha.dagger.io/dagger"
"alpha.dagger.io/dagger/op"
)
// Build a Docker image from source, using included Dockerfile
#Build: {
source: dagger.#Input & {dagger.#Artifact}
args?: [string]: string
#up: [
op.#DockerBuild & {
context: source
if args != _|_ {
buildArg: args
}
},
]
}
// Pull a docker container
#Pull: {
// Remote ref (example: "index.docker.io/alpine:latest")
from: dagger.#Input & {string}
#up: [
op.#FetchContainer & {ref: from},
]
}
// Push a docker image to a remote registry
#Push: {
// Remote target (example: "index.docker.io/alpine:latest")
target: dagger.#Input & {string}
// Image source
source: dagger.#Input & {dagger.#Artifact}
// Registry auth
auth?: {
// Username
username: dagger.#Input & {string}
// Password or secret
secret: dagger.#Input & {dagger.#Secret | string}
}
push: #up: [
op.#Load & {from: source},
if auth != _|_ {
op.#DockerLogin & {
"target": target
username: auth.username
secret: auth.secret
}
},
op.#PushContainer & {ref: target},
op.#Subdir & {dir: "/dagger"},
]
// Image ref
ref: {
string
#up: [
op.#Load & {from: push},
op.#Export & {
source: "/image_ref"
},
]
} & dagger.#Output
// Image digest
digest: {
string
#up: [
op.#Load & {from: push},
op.#Export & {
source: "/image_digest"
},
]
} & dagger.#Output
}
#Run: {
// Connect to a remote SSH server
ssh: {
// ssh host
host: dagger.#Input & {string}
// ssh user
user: dagger.#Input & {string}
// ssh port
port: dagger.#Input & {*22 | int}
// private key
key: dagger.#Input & {dagger.#Secret}
// fingerprint
fingerprint?: dagger.#Input & {string}
// ssh key passphrase
keyPassphrase?: dagger.#Input & {dagger.#Secret}
}
// Image reference (e.g: nginx:alpine)
ref: dagger.#Input & {string}
// Container name
name?: dagger.#Input & {string}
// Image registry
registry?: {
target: string
username: string
secret: dagger.#Secret
} & dagger.#Input
#command: #"""
# Run detach container
OPTS=""
if [ ! -z "$CONTAINER_NAME" ]; then
OPTS="$OPTS --name $CONTAINER_NAME"
fi
docker container run -d $OPTS "$IMAGE_REF"
"""#
run: #Command & {
"ssh": ssh
command: #command
env: {
IMAGE_REF: ref
if name != _|_ {
CONTAINER_NAME: name
}
}
}
}
// 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
},
]
}