From 4323603e13036423746d5dd5047d8a56b8102e52 Mon Sep 17 00:00:00 2001 From: Kenneth Bingham Date: Wed, 23 Aug 2023 08:47:14 -0400 Subject: [PATCH] create builder unless existing builder --- quickstart/docker/README.md | 17 ++++------------- quickstart/docker/image/fetch-ziti-bins.sh | 6 +++--- quickstart/docker/pushLatestDocker.sh | 11 +++++++---- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/quickstart/docker/README.md b/quickstart/docker/README.md index b6ebbf772..733b9c287 100644 --- a/quickstart/docker/README.md +++ b/quickstart/docker/README.md @@ -21,25 +21,16 @@ First, decide what you are trying to do. Are you trying to: 1. change to this directory from checkout root: `cd quickstart/docker` 1. run the script `./createLocalImage.sh` which will create a `openziti/quickstart:latest` tag using the latest `ziti` [release from GitHub](https://github.com/openziti/ziti/releases/latest) - 1. Optionally, you may provide an argument for the image tag. `./createLocalImage.sh ` + 1. Optionally, you may provide an argument, e.g., `./createLocalImage.sh `, to create a tag + other than `latest`. ## Build Docker Image with Specific ziti Version 1. change to this directory from checkout root: `cd quickstart/docker` 1. set `ZITI_VERSION_OVERRIDE` to desired version: `export ZITI_VERSION_OVERRIDE=v0.28.4` 1. run the script `./createLocalImage.sh` which will create a `openziti/quickstart:latest` tag using the specified version of `ziti` [from GitHub](https://github.com/openziti/ziti/releases/tag/v0.28.4) - 1. Optionally, you may provide an argument for the image tag. `./createLocalImage.sh ` - -## ERROR: existing instance for "ziti-builder" -When running the `./createLocalImage.sh` script, you might get this error: -``` -ERROR: existing instance for "ziti-builder" but no append mode, specify --node to make changes for existing instances -``` -It's probably safest to just remove the buildx builder using: -``` -docker buildx rm ziti-builder -``` - + 1. Optionally, you may provide an argument, e.g., `./createLocalImage.sh `, to create a tag + other than `latest`. ## Build Docker Image For Publication To publish the latest `ziti` CLI, use [the GitHub Action](https://github.com/openziti/ziti/actions/workflows/push-quickstart.yml). diff --git a/quickstart/docker/image/fetch-ziti-bins.sh b/quickstart/docker/image/fetch-ziti-bins.sh index 22792cfa7..0b20e3eec 100644 --- a/quickstart/docker/image/fetch-ziti-bins.sh +++ b/quickstart/docker/image/fetch-ziti-bins.sh @@ -7,7 +7,7 @@ dest="${1}" if [ -d /docker.build.context/ziti-bin ]; then mv /docker.build.context/ziti-bin/ "${dest}" else - source /docker.build.context/ziti-cli-functions.sh - getZiti - mv "${ZITI_BIN_DIR}" "${dest}" + source /docker.build.context/ziti-cli-functions.sh + getZiti + mv "${ZITI_BIN_DIR}" "${dest}" fi diff --git a/quickstart/docker/pushLatestDocker.sh b/quickstart/docker/pushLatestDocker.sh index d93d1780b..557fc26a5 100755 --- a/quickstart/docker/pushLatestDocker.sh +++ b/quickstart/docker/pushLatestDocker.sh @@ -21,8 +21,6 @@ if [ -z "${IMAGE_TAG}" ]; then echo "image tag name was not provided, using default '${IMAGE_TAG}'" fi -docker buildx create --use --name=ziti-builder - if [ "local" == "${1}" ]; then echo "LOADING LOCALLY instead of pushing to dockerhub" _BUILDX_PLATFORM="" @@ -31,8 +29,13 @@ else _BUILDX_PLATFORM="--platform linux/amd64,linux/arm64" _BUILDX_ACTION="--push" fi -docker buildx build ${_BUILDX_PLATFORM} "${SCRIPT_DIR}/image" \ + +docker buildx create \ + --use --name=ziti-builder --driver docker-container 2>/dev/null \ + || docker buildx use --default ziti-builder + +eval docker buildx build "${_BUILDX_PLATFORM}" "${SCRIPT_DIR}/image" \ --build-arg ZITI_VERSION_OVERRIDE="v${ZITI_VERSION}" \ --tag "openziti/quickstart:${ZITI_VERSION}" \ --tag "openziti/quickstart:${IMAGE_TAG}" \ - ${_BUILDX_ACTION} \ No newline at end of file + "${_BUILDX_ACTION}"