diff --git a/tools/docker/core/hooks/post_push b/tools/docker/core/hooks/post_push deleted file mode 100644 index bc700783e..000000000 --- a/tools/docker/core/hooks/post_push +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -set -ex - -WORK_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" -source "$WORK_DIR/../../lib/common" - -for TARGET_ARCH in "${ALL_TARGET_ARCH[@]}"; do - TagDockerImageAliases "${TARGET_ARCH}" - PushDockerImageAliases "${TARGET_ARCH}" -done diff --git a/tools/docker/core/hooks/push b/tools/docker/core/hooks/push deleted file mode 100644 index 0102c5d4d..000000000 --- a/tools/docker/core/hooks/push +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -set -ex - -WORK_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" -source "$WORK_DIR/../../lib/common" - -for TARGET_ARCH in "${ALL_TARGET_ARCH[@]}"; do - PushDockerImage "${TARGET_ARCH}" -done diff --git a/tools/docker/deploy.sh b/tools/docker/deploy.sh index 89802f264..65547aa4c 100755 --- a/tools/docker/deploy.sh +++ b/tools/docker/deploy.sh @@ -14,22 +14,53 @@ IFS=$'\n\t' WORK_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" -Deploy() { - DOCKER_REPO="$1" - TAG_BASE="$2" - DOCKERFILE_DIR="$3" - DOCKERFILE_PATH="$DOCKERFILE_DIR/Dockerfile" - DOCKER_TAG="$TAG_BASE" DOCKER_REPO="$DOCKER_REPO" DOCKERFILE_PATH="$DOCKERFILE_PATH" bash "$DOCKERFILE_DIR/hooks/push" - DOCKER_TAG="$TAG_BASE" DOCKER_REPO="$DOCKER_REPO" DOCKERFILE_PATH="$DOCKERFILE_PATH" bash "$DOCKERFILE_DIR/hooks/post_push" -} - TAG_BASE="$1" # Eg. v0.35.0 or nightly source "$WORK_DIR/lib/common" +# Creates and pushes all Docker images aliases for all architectures. +# If the value of the global variable TAG_BASE is a version tag such as +# v0.35.0, the "latest" tag is also updated. Tags without the architecture part +# are also created for the default architecture. +# As an example, for amd64 (the default architecture) and the tag v0.35.0, the +# following tags would be created: +# - certbot/certbot:v0.35.0 +# - certbot/certbot:latest +# - certbot/certbot:amd64-latest +# For the architecture arm32v6 and the tag v0.35.0, only the following tag +# would be created: +# - certbot/certbot:arm32v6-latest +# For other tags such as "nightly", aliases are only created for the default +# architecture where the tag "nightly" would be used without an architecture +# part. +# Usage: TagAndPush [IMAGE NAME] +# where [IMAGE NAME] is the name of the Docker image in the Docker repository +# such as "certbot" or "dns-cloudflare". +# Read globals: +# * TAG_BASE +TagAndPushForAllArch() { + DOCKER_REPO="${DOCKER_HUB_ORG}/${1}" + for TARGET_ARCH in "${ALL_TARGET_ARCH[@]}"; do + docker push "${DOCKER_REPO}:${TARGET_ARCH}-${TAG_BASE}" + + if [[ "${TAG_BASE}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + docker tag "${DOCKER_REPO}:${TARGET_ARCH}-${TAG_BASE}" "${DOCKER_REPO}:${TARGET_ARCH}-latest" + docker push "${DOCKER_REPO}:${TARGET_ARCH}-latest" + if [ "${TARGET_ARCH}" == "${DEFAULT_ARCH}" ]; then + docker tag "${DOCKER_REPO}:${TARGET_ARCH}-${TAG_BASE}" "${DOCKER_REPO}:latest" + docker push "${DOCKER_REPO}:latest" + fi + fi + if [ "${TARGET_ARCH}" == "${DEFAULT_ARCH}" ]; then + docker tag "${DOCKER_REPO}:${TARGET_ARCH}-${TAG_BASE}" "${DOCKER_REPO}:${TAG_BASE}" + docker push "${DOCKER_REPO}:${TAG_BASE}" + fi + done +} + # Step 1: Certbot core Docker -Deploy "$DOCKER_HUB_ORG/certbot" "$TAG_BASE" "$WORK_DIR/core" +TagAndPushForAllArch "certbot" # Step 2: Certbot DNS plugins Docker images for plugin in "${CERTBOT_PLUGINS[@]}"; do - Deploy "$DOCKER_HUB_ORG/$plugin" "$TAG_BASE" "$WORK_DIR/plugin" + TagAndPushForAllArch "${plugin}" done diff --git a/tools/docker/lib/common b/tools/docker/lib/common index e14ab546a..1dd62aff4 100644 --- a/tools/docker/lib/common +++ b/tools/docker/lib/common @@ -31,57 +31,3 @@ export CERTBOT_PLUGINS=( "dns-linode" "dns-sakuracloud" ) - -# Pushes docker image for a specific architecture. -# Usage: BuildDockerCoreImage [amd64|arm32v6|arm64v8] -PushDockerImage() { - ARCH=$1 - - docker push "${DOCKER_REPO}:${ARCH}-${DOCKER_TAG}" -} - -# Creates any docker images aliases for a given architecture. -# If DOCKER_TAG tag is a version tag such as v0.35.0, the "latest" tag is also -# updated. In the case of the default architecture, tags without the -# architecture part are also created. -# As an example, for amd64 (the default architecture) and the tag v0.35.0, the -# following tags would be created: -# - certbot/certbot:v0.35.0 -# - certbot/certbot:latest -# - certbot/certbot:amd64-latest -# For the architecture arm32v6 and the tag v0.35.0, only the following tag -# would be created: -# - certbot/certbot:arm32v6-latest -# For other tags such as "nightly", aliases are only created for the default -# architecture where the tag "nightly" would be used without an architecture -# part. -# Usage: TagDockerImageAliases [amd64|arm32v6|arm64v8] -TagDockerImageAliases() { - ARCH=$1 - - if [[ "${DOCKER_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - docker tag "${DOCKER_REPO}:${ARCH}-${DOCKER_TAG}" "${DOCKER_REPO}:${ARCH}-latest" - if [ "${ARCH}" == "${DEFAULT_ARCH}" ]; then - docker tag "${DOCKER_REPO}:${ARCH}-${DOCKER_TAG}" "${DOCKER_REPO}:latest" - fi - fi - if [ "${ARCH}" == "${DEFAULT_ARCH}" ]; then - docker tag "${DOCKER_REPO}:${ARCH}-${DOCKER_TAG}" "${DOCKER_REPO}:${DOCKER_TAG}" - fi -} - -# Pushes docker images aliases created by the TagDockerImageAliases function. -# Usage: PushDockerImageAliases [amd64|arm32v6|arm64v8] -PushDockerImageAliases() { - ARCH=$1 - - if [[ "${DOCKER_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - docker push "${DOCKER_REPO}:${ARCH}-latest" - if [ "${ARCH}" == "${DEFAULT_ARCH}" ]; then - docker push "${DOCKER_REPO}:latest" - fi - fi - if [ "${ARCH}" == "${DEFAULT_ARCH}" ]; then - docker push "${DOCKER_REPO}:${DOCKER_TAG}" - fi -} diff --git a/tools/docker/plugin/hooks/post_push b/tools/docker/plugin/hooks/post_push deleted file mode 100644 index bc700783e..000000000 --- a/tools/docker/plugin/hooks/post_push +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -set -ex - -WORK_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" -source "$WORK_DIR/../../lib/common" - -for TARGET_ARCH in "${ALL_TARGET_ARCH[@]}"; do - TagDockerImageAliases "${TARGET_ARCH}" - PushDockerImageAliases "${TARGET_ARCH}" -done diff --git a/tools/docker/plugin/hooks/push b/tools/docker/plugin/hooks/push deleted file mode 100644 index 0102c5d4d..000000000 --- a/tools/docker/plugin/hooks/push +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -set -ex - -WORK_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" -source "$WORK_DIR/../../lib/common" - -for TARGET_ARCH in "${ALL_TARGET_ARCH[@]}"; do - PushDockerImage "${TARGET_ARCH}" -done