From 9f16bcdadb4c2c6c8861f5d08ba07423f664926d Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Mon, 27 Sep 2021 16:55:01 -0600 Subject: [PATCH] added ports to docker.#Run Signed-off-by: Richard Jones --- stdlib/docker/docker.cue | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/stdlib/docker/docker.cue b/stdlib/docker/docker.cue index 3b26dfd8..85f781b3 100644 --- a/stdlib/docker/docker.cue +++ b/stdlib/docker/docker.cue @@ -2,6 +2,7 @@ package docker import ( + "strings" "alpha.dagger.io/dagger" "alpha.dagger.io/dagger/op" ) @@ -138,6 +139,9 @@ import ( secret: dagger.#Secret } & dagger.#Input + // local ports + ports?: [...string] + #command: #""" # Run detach container OPTS="" @@ -146,6 +150,10 @@ import ( OPTS="$OPTS --name $CONTAINER_NAME" fi + if [ ! -z "$CONTAINER_PORTS" ]; then + OPTS="$OPTS -p $CONTAINER_PORTS" + fi + docker container run -d $OPTS "$IMAGE_REF" """# @@ -163,6 +171,10 @@ import ( if name != _|_ { CONTAINER_NAME: name } + + if ports != _|_ { + CONTAINER_PORTS: strings.Join(ports," -p ") + } } } }