From eaa965127aa73a63940b924efc9473f309897b10 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Tue, 21 Sep 2021 17:19:00 -0700 Subject: [PATCH] stdlib: added support for local docker socket Signed-off-by: Sam Alba --- stdlib/docker/command.cue | 6 ++++++ stdlib/docker/compose/compose.cue | 11 ++++++++++- stdlib/docker/docker.cue | 13 +++++++++++-- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/stdlib/docker/command.cue b/stdlib/docker/command.cue index e51f1aec..ac28e152 100644 --- a/stdlib/docker/command.cue +++ b/stdlib/docker/command.cue @@ -57,6 +57,9 @@ import ( [string]: true @dagger(input) } + // Mount docker socket + socket?: dagger.#Stream @dagger(input) + // Additional packages to install package: { [string]: true | false | string @dagger(input) @@ -213,6 +216,9 @@ import ( "/keyPassphrase": secret: ssh.keyPassphrase } } + if socket != _|_ { + "/var/run/docker.sock": stream: socket + } for dest, o in mount { "\(dest)": o } diff --git a/stdlib/docker/compose/compose.cue b/stdlib/docker/compose/compose.cue index 77067ec2..85d42052 100644 --- a/stdlib/docker/compose/compose.cue +++ b/stdlib/docker/compose/compose.cue @@ -28,6 +28,9 @@ import ( keyPassphrase?: dagger.#Secret @dagger(input) } + // Mount local docker socket + socket?: dagger.#Stream & dagger.#Input + // Accept either a contaxt, a docker-compose or both together source?: dagger.#Artifact @dagger(input) composeFile?: string @dagger(input) @@ -65,7 +68,13 @@ import ( """# run: docker.#Command & { - "ssh": ssh + if ssh != _|_ { + "ssh": ssh + } + if socket != _|_ { + "socket": socket + } + command: #code package: "docker-compose": true "registries": registries diff --git a/stdlib/docker/docker.cue b/stdlib/docker/docker.cue index 98fabd81..00a2d21e 100644 --- a/stdlib/docker/docker.cue +++ b/stdlib/docker/docker.cue @@ -102,7 +102,7 @@ import ( #Run: { // Connect to a remote SSH server - ssh: { + ssh?: { // ssh host host: dagger.#Input & {string} @@ -122,6 +122,9 @@ import ( keyPassphrase?: dagger.#Input & {dagger.#Secret} } + // Mount local docker socket + socket?: dagger.#Stream & dagger.#Input + // Image reference (e.g: nginx:alpine) ref: dagger.#Input & {string} @@ -147,7 +150,13 @@ import ( """# run: #Command & { - "ssh": ssh + if ssh != _|_ { + "ssh": ssh + } + if socket != _|_ { + "socket": socket + } + command: #command env: { IMAGE_REF: ref