Add a `--skip-build` option to docker image builds (#23836)
* add a skip-build argument to build.sh, to allow pushing without building, assuming an image is already built
* Restyle
* Fix conditional
diff --git a/integrations/docker/build.sh b/integrations/docker/build.sh
index cb063a2..8336b26 100755
--- a/integrations/docker/build.sh
+++ b/integrations/docker/build.sh
@@ -46,11 +46,12 @@
Build and (optionally tag as latest, push) a docker image from Dockerfile in CWD
Options:
- --no-cache passed as a docker build argument
- --latest update latest to the current built version (\"$VERSION\")
- --push push image(s) to docker.io (requires docker login for \"$ORG\")
- --help get this message
- --squash squash docker layers before push them to docker.io (requires docker-squash python module)
+ --no-cache passed as a docker build argument
+ --latest update latest to the current built version (\"$VERSION\")
+ --push push image(s) to docker.io (requires docker login for \"$ORG\")
+ --skip-build skip the build/prune step
+ --help get this message
+ --squash squash docker layers before push them to docker.io (requires docker-squash python module)
"
exit 0
@@ -80,8 +81,10 @@
BUILD_ARGS+=(--no-cache)
fi
-docker build "${BUILD_ARGS[@]}" --build-arg VERSION="$VERSION" -t "$ORG/$IMAGE:$VERSION" .
-docker image prune --force
+[[ ${*/--skip-build//} != "${*}" ]] || {
+ docker build "${BUILD_ARGS[@]}" --build-arg VERSION="$VERSION" -t "$ORG/$IMAGE:$VERSION" .
+ docker image prune --force
+}
[[ ${*/--latest//} != "${*}" ]] && {
docker tag "$ORG"/"$IMAGE":"$VERSION" "$ORG"/"$IMAGE":latest