mirror of
https://github.com/certbot/certbot.git
synced 2026-06-06 07:12:54 -04:00
Fixes https://github.com/certbot/certbot/issues/8022, https://github.com/certbot-docker/certbot-docker/issues/25, and https://github.com/certbot-docker/certbot-docker/issues/20. This PR builds on https://github.com/certbot/certbot/pull/8192 to set up similar builds in Azure to what we currently have at release time as well as nightly builds allowing us to catch problems in these images before a release. It also fully automates our Docker deployments removing a manual step from our release process. We'll need to update our release instructions once this PR lands. If you're not familiar with our `certbot-docker` setup, you can read about how these scripts customized the build process on Docker Hub at https://docs.docker.com/docker-hub/builds/advanced/. You can see the process working properly at: * Nightly build on my fork: https://dev.azure.com/bmw0523/bmw/_build/results?buildId=345&view=logs&j=70ac378a-cb1f-50d1-b328-169807afbcfa * Release build on my fork: https://dev.azure.com/bmw0523/bmw/_build/results?buildId=346&view=logs&j=70ac378a-cb1f-50d1-b328-169807afbcfa * Nightly build on Certbot's Azure setup: https://dev.azure.com/certbot/certbot/_build/results?buildId=2426&view=logs&j=70ac378a-cb1f-50d1-b328-169807afbcfa The builds on my fork pushed to https://hub.docker.com/u/certbottest. The credentials for this account are in our shared vault in 1password if you want to play around with this. While the scripts will (almost?) always be run in CI, I tested the scripts successfully on macOS, Ubuntu 18.04, and Ubuntu 20.04, however, **the scripts do not seem to work when using the Docker snap, at least on Ubuntu 20.04.** It does work with the `docker.io` packages from `apt`. I was able to make things work by no longer setting `DOCKER_BUILDKIT`, but as I described in the code comments, this breaks things on Azure. When writing this PR, I tried to make the minimal modifications to our current set up to get the behavior we want. I'm planning on working on splitting the Docker builds into different Azure jobs so it doesn't increase the overall build time, but this isn't trivial so I figured it would be best done in a separate PR. * Remove license. * update build scripts * write deploy code * Remove unused READMEs. * rewrite readme * Make testing on a fork easier. * Set up Azure automation. * fix typo * Make output more verbose. * clean up cleanup...everybody everywhere * separate build and deploy * Document docker-hub credentials * Use Docker BuildKit when building. * Remove unneeded .gitignore files. * Fix tools/docker/README.md grammar Co-authored-by: ohemorange <ebportnoy@gmail.com> * Clarify <TAG> in README. * no docker snap * rename docker job Co-authored-by: Erica Portnoy <ebportnoy@gmail.com>
160 lines
4.9 KiB
Bash
160 lines
4.9 KiB
Bash
#!/bin/bash
|
|
set -ex
|
|
|
|
# Current supported architectures
|
|
export ALL_TARGET_ARCH=(amd64 arm32v6 arm64v8)
|
|
|
|
# Architecture used in tags with no architecture specified (certbot/certbot:latest, certbot/certbot:v0.35.0, ...)
|
|
export DEFAULT_ARCH=amd64
|
|
|
|
# Name of the Certbot Docker organizaation on GitHub. After creating
|
|
# repositories with the same names (e.g. "certbot", "dns-dnsmadeeasy", etc.)
|
|
# using a different account on Docker Hub, you can change this value to have
|
|
# the scripts modify those Docker repositories rather than the repositories for
|
|
# the official Certbot Docker images.
|
|
export DOCKER_HUB_ORG="certbot"
|
|
|
|
# List of Certbot plugins
|
|
export CERTBOT_PLUGINS=(
|
|
"dns-dnsmadeeasy"
|
|
"dns-dnsimple"
|
|
"dns-ovh"
|
|
"dns-cloudflare"
|
|
"dns-cloudxns"
|
|
"dns-digitalocean"
|
|
"dns-google"
|
|
"dns-luadns"
|
|
"dns-nsone"
|
|
"dns-rfc2136"
|
|
"dns-route53"
|
|
"dns-gehirn"
|
|
"dns-linode"
|
|
"dns-sakuracloud"
|
|
)
|
|
|
|
# Returns the translation from Docker to QEMU architecture
|
|
# Usage: GetQemuArch [amd64|arm32v6|arm64v8]
|
|
GetQemuArch() {
|
|
ARCH=$1
|
|
|
|
case "$ARCH" in
|
|
"amd64")
|
|
echo "x86_64"
|
|
;;
|
|
"arm32v6")
|
|
echo "arm"
|
|
;;
|
|
"arm64v8")
|
|
echo "aarch64"
|
|
;;
|
|
"*")
|
|
echo "Not supported build architecture '$1'." >&2
|
|
exit -1
|
|
esac
|
|
}
|
|
|
|
# Downloads QEMU static binary file for architecture
|
|
# Usage: DownloadQemuStatic [x86_64|arm|aarch64]
|
|
DownloadQemuStatic() {
|
|
ARCH=$1
|
|
|
|
QEMU_ARCH=$(GetQemuArch "$ARCH")
|
|
if [ ! -f "qemu-${QEMU_ARCH}-static" ]; then
|
|
QEMU_DOWNLOAD_URL="https://github.com/multiarch/qemu-user-static/releases/download"
|
|
QEMU_LATEST_TAG=$(curl -s https://api.github.com/repos/multiarch/qemu-user-static/tags \
|
|
| grep 'name.*v[0-9]' \
|
|
| head -n 1 \
|
|
| cut -d '"' -f 4)
|
|
curl -SL "${QEMU_DOWNLOAD_URL}/${QEMU_LATEST_TAG}/x86_64_qemu-$QEMU_ARCH-static.tar.gz" \
|
|
| tar xzv
|
|
fi
|
|
}
|
|
|
|
# Executes the QEMU register script
|
|
# Usage: RegisterQemuHandlers
|
|
RegisterQemuHandlers() {
|
|
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
|
}
|
|
|
|
# Builds docker certbot core image for a specific architecture.
|
|
# Usage: BuildDockerCoreImage [amd64|arm32v6|arm64v8]
|
|
BuildDockerCoreImage() {
|
|
ARCH=$1
|
|
|
|
QEMU=$(GetQemuArch "$ARCH")
|
|
docker build \
|
|
--build-arg TARGET_ARCH="${ARCH}" \
|
|
--build-arg QEMU_ARCH="${QEMU}" \
|
|
-f "${DOCKERFILE_PATH}" \
|
|
-t "${DOCKER_REPO}:${ARCH}-${DOCKER_TAG}" \
|
|
.
|
|
}
|
|
|
|
# Builds docker certbot plugin image for a specific architecture and tag.
|
|
# Usage: BuildDockerPluginImage [amd64|arm32v6|arm64v8]
|
|
BuildDockerPluginImage() {
|
|
ARCH=$1
|
|
|
|
QEMU=$(GetQemuArch "$ARCH")
|
|
BASE_IMAGE="${DOCKER_HUB_ORG}/certbot:${TARGET_ARCH}-${DOCKER_TAG}"
|
|
docker build \
|
|
--build-arg BASE_IMAGE="${BASE_IMAGE}" \
|
|
--build-arg QEMU_ARCH="${QEMU}" \
|
|
-f "${DOCKERFILE_PATH}" \
|
|
-t "${DOCKER_REPO}:${ARCH}-${DOCKER_TAG}" \
|
|
.
|
|
}
|
|
|
|
# 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
|
|
}
|