From 4bd38309a66a7d4fe17ff00b21febece994c251e Mon Sep 17 00:00:00 2001 From: Kenneth Bingham Date: Sat, 4 Jan 2025 12:32:23 -0500 Subject: [PATCH] delete obsolete docker build instructions --- docker/BUILD.md | 149 ----------------------------------------------- docker/buildx.sh | 123 -------------------------------------- 2 files changed, 272 deletions(-) delete mode 100644 docker/BUILD.md delete mode 100755 docker/buildx.sh diff --git a/docker/BUILD.md b/docker/BUILD.md deleted file mode 100644 index 38778efe..00000000 --- a/docker/BUILD.md +++ /dev/null @@ -1,149 +0,0 @@ - -# Building the ziti-edge-tunnel Docker Images - -The Dockerfile and scripts in this directory build a `ziti-edge-tunnel` (tunneler from C-SDK) Docker image. - -Ziti binaries are downloaded from https://github.com/openziti/ziti-tunnel-sdk-c/ -by default. The following build arguments are supported: - - | Build Argument | Description | - | -------------------- | ----------------------------------------------------------------- | - | ZITI_VERSION | The version of the ziti binaries to fetch from artifactory. | - | GITHUB_BASE_URL | Defaults to "https://github.com/openziti". | - | GITHUB_REPO | Defaults to "ziti-tunnel-sdk-c". | - -# Building multi-platform Images - -Use this build method if you're pushing the ziti-edge-tunnel image to a public image -registry. - -This build method creates images for the amd64 and arm/v7 platforms, but it -requires experimental Docker features and may involve more setup than you're -willing to endure. See "Building for Development" if you just want to build the -ziti-edge-tunnel image for use on your local workstation, and don't plan on pushing -the image to a public registry. - -## Prerequisites - -1. Enable Docker Experimental Features - - See https://docs.docker.com/engine/reference/commandline/cli/#experimental-features - -2. Install & Enable qemu Emulation for Arm (Docker CE / Linux only) - - This is taken care of by Docker Desktop if you're building on macOS or Windows, - but you'll need to install qemu emulation support and register Arm binaries to - run on your (presumably) x86_64 build host if you are running Docker CE on Linux: - - ```bash - sudo dnf install -y qemu-system-arm - docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d - ``` - -3. Verify that the Arm qemu handler is registered. The first line of the file is "enabled". - - ```bash - $ cat /proc/sys/fs/binfmt_misc/qemu-arm - enabled - interpreter /usr/bin/qemu-arm - ``` - - Optionally, run an ARM arch container and print system information to test qemu-arm - - ```bash - $ docker run --rm arm64v8/alpine uname -a - Linux 00eea7912eb1 5.11.0-7612-generic #13~1617215757~20.10~97a8d1a-Ubuntu SMP Thu Apr 1 21:09:17 UTC 2 aarch64 Linux - - $ docker run --rm arm32v7/alpine uname -a - Linux 6fcaad6c8b37 5.11.0-7612-generic #13~1617215757~20.10~97a8d1a-Ubuntu SMP Thu Apr 1 21:09:17 UTC 2 armv7l Linux - ``` - -4. Create a Builder Instance - - ```bash - docker buildx create --use --name=ziti-builder - ``` - -## Building - -Run `docker buildx` like this: - -```bash -$ git fetch --tags && git tag -l | sort -Vr | head -1 -v0.16.1 -$ ZITI_VERSION="0.16.1" -$ docker buildx build \ - --platform linux/amd64,linux/arm/v7,linux/aarch64 \ - --build-arg ZITI_VERSION="${ZITI_VERSION}" \ - -t "netfoundry/ziti-edge-tunnel:${ZITI_VERSION}" . -``` - -Notes: - -- You'll need to append `--push` to this command, and then subsequently pull the - image to be able to use the image locally. - - Unfortunately `buildx` doesn't currently support building images directly into - the local docker cache. Although the `--load` and `--output=type=docker` options - exist, the underlying capability to load a multi-platform image (OCI) will be - implemented in a future Docker release (see https://github.com/docker/buildx/issues/59). - In the meantime, you'll need to push your image builds (with the `--push` build option) - and then pull them to run the image locally when building with `buildx`. - -- The armv8 image uses armv7 (32-bit) ziti executables. The 32-bit compatibility - libraries are installed in the image, but your Arm CPU must support 32-bit emulation. - -## References - -- -- -- -- - -# Building for Development - -This build method produces an image for the CPU that is running the build host -(typically amd64), and places the resulting image into your local Docker image -cache. - -```bash -ZITI_VERSION=$( - curl -sSf https://api.github.com/repos/openziti/ziti-tunnel-sdk-c/releases/latest \ - | jq -r '.tag_name' \ - | sed -E 's/^v//' -); - -docker buildx build \ - --tag ziti-edge-tunnel:${ZITI_VERSION} \ - --build-arg ZITI_VERSION=${ZITI_VERSION} \ - --file ./docker/Dockerfile.base \ - --load \ - ./docker - -docker buildx build \ - --tag ziti-host:${ZITI_VERSION} \ - --build-arg ZITI_EDGE_TUNNEL_IMAGE=ziti-edge-tunnel \ - --build-arg ZITI_EDGE_TUNNEL_TAG=${ZITI_VERSION} \ - --file ./docker/Dockerfile.ziti-host \ - --load \ - ./docker -``` - -## Shell Script for Linux - -```bash -$ ./buildx.sh -h -Usage: VARIABLES ./buildx.sh [OPTION]... - -Build multi-platform Docker container image on Linux. - -VARIABLES - ZITI_VERSION e.g. "0.16.1" corresponding to Git tag "v0.16.1" - -OPTIONS - -r REPO container image repository e.g. netfoundry/ziti-edge-tunnel - -c don't check out v${ZITI_VERSION} (use Git working copy) - -EXAMPLES - ZITI_VERSION=0.16.1 ./buildx.sh -r netfoundry/ziti-edge-tunnel -``` diff --git a/docker/buildx.sh b/docker/buildx.sh deleted file mode 100755 index 79d81e0a..00000000 --- a/docker/buildx.sh +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright NetFoundry Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -set -euo pipefail - -_usage(){ - cat >&2 <<-EOF -Usage: VARIABLES ./buildx.sh [OPTION]... - -Build multi-platform Docker container image on Linux. - -VARIABLES - ZITI_VERSION e.g. "0.16.1" corresponding to Git tag "v0.16.1" - -OPTIONS - -r REPO container image repository e.g. netfoundry/ziti-edge-tunnel - -c don't check out v\${ZITI_VERSION} (use Git working copy) - -l additionally tag ziti-edge-tunnel:latest - -f clobber Docker registry tag if it exists - - -EXAMPLES - ZITI_VERSION=0.16.1 ./buildx.sh -c - -REFERENCE - https://github.com/openziti/ziti-tunnel-sdk-c/blob/main/docker/BUILD.md -EOF - if [[ $# -eq 1 ]]; then - return "$1" - else - return 0 - fi -} - -#BASENAME=$(basename $0) || exit $? -DIRNAME=$(dirname "$0") || exit $? -EXIT=0 - -while getopts :r:chlfP OPT;do - case $OPT in - r) CONTAINER_REPO=$OPTARG - ;; - c) FLAGS+=$OPT # don't checkout vZITI_VERSION - ;; - h) _usage; exit 0 # not an error - ;; - l) FLAGS+=$OPT # also tag and push latest - ;; - f) FLAGS+=$OPT # clobber existing tag(s) in Hub - ;; - P) FLAGS+=$OPT # don't push container image to Hub - ;; - \?|*) _usage 1 # error - ;; - esac -done -shift "$((OPTIND-1))" - -# default to latest -: "${ZITI_VERSION:=$(git fetch --quiet --tags && git tag -l|sort -Vr|head -1|sed -E 's/^v(.*)/\1/')}" - -# required opts -if [[ -z "${CONTAINER_REPO:-}" ]]; then - echo "ERROR: missing -r REPO option to define container image repository name for image push" >&2 - _usage; exit 1 -else - TAG_PARAMS="--tag=\"${CONTAINER_REPO}:${ZITI_VERSION}\"" -fi - -if [[ ${FLAGS:-} =~ c ]]; then - echo "WARN: not checking out Git tag v${ZITI_VERSION}" -else - git diff --exit-code # bail if unstaged differences - git fetch --tags - git checkout "v${ZITI_VERSION}" -fi - -if [[ ${FLAGS:-} =~ l ]]; then - TAG_PARAMS+=" --tag=\"${CONTAINER_REPO}:latest\"" -fi - -if [[ ${FLAGS:-} =~ P ]]; then - # if no push then load in image cache - BUILDX_OUTPUT="" -else - # default is push to Hub - BUILDX_OUTPUT="--push" -fi - -docker run --rm --privileged tonistiigi/binfmt:qemu-v6.2.0 -grep -E -q 'enabled' /proc/sys/fs/binfmt_misc/qemu-arm -docker run --rm --platform linux/arm64/v8 arm64v8/alpine uname -a | grep -Eq 'aarch64 Linux' -docker run --rm --platform linux/arm/v7 arm32v7/alpine uname -a | grep -Eq 'armv7l Linux' -docker buildx create --use --name=ziti-builder 2>/dev/null || docker buildx use --default ziti-builder - -# if -if [[ ${FLAGS:-} =~ P ]] || [[ ${FLAGS:-} =~ f ]] || ! curl -sSLf https://registry.hub.docker.com/v2/repositories/${CONTAINER_REPO}/tags/${ZITI_VERSION} &>/dev/null; then - eval docker buildx build "${DIRNAME}" \ - --platform="linux/amd64,linux/arm/v7,linux/arm64" \ - --build-arg=ZITI_VERSION="${ZITI_VERSION}" \ - "${TAG_PARAMS}" \ - "${BUILDX_OUTPUT}" -else - echo "ERROR: Docker tag ziti-edge-tunnel:${ZITI_VERSION} already exists. Carefully send option -f to clobber Docker image tag." >&2 - EXIT=1 -fi -docker buildx stop ziti-builder - -exit $EXIT \ No newline at end of file