mirror of
https://github.com/certbot/certbot.git
synced 2026-01-26 07:41:33 +03:00
* Add one Dockerfile for each supported architecture
* Update multi arch hooks
* Create multi arch scripts
* Update README.md
* WIP. Use build args instead of multiple Dockerfiles in build script
* WIP. Fix typo mistake
* Use build args instead of multiple Dockerfiles in build script
* WIP. Build all the architectures in one DockerHub build
* Add arm64v8 architecture
* WIP. Testing build all the architectures in one DockerHub build
* Revert "WIP. Testing build all the architectures in one DockerHub build"
This reverts commit 94a89398a4120b183d2851ac7cb9c93db0e3d187.
* Refactor tag docker images in hooks/post_push files
* Use variables instead of positional arguments
* Export externally used variables
* Use ${variable//search/replace} instead of echo $variable | sed.
* Update README.md
* Add Cleanup in build.sh script
* Fix tagging error in post_push hook
* Add "-ex" flags to bash script
* Test tagging images in build hook
* Tagging in hook/post_build instead of hook/post_push
* Push built architecture dependent image
* Use Dockerfile argument instead of fixed value
* Fix typo
* Use parameter instead of global variable
* Use custom "hook/push" to prevent duplicated push
* Make a short doctype for each function declared in common
143 lines
4.5 KiB
Bash
143 lines
4.5 KiB
Bash
#!/bin/bash
|
|
set -ex
|
|
|
|
# Current supported architectures
|
|
export ALL_TARGET_ARCH=(amd64 arm32v6 arm64v8)
|
|
|
|
# Architecture used in tags with no architecture especified (certbot/certbot:latest, certbot/cerbot:v0.35.0, ...)
|
|
export DEFAULT_ARCH=amd64
|
|
|
|
# Returns certbot version (ex. v0.35.0 returns 0.35.0)
|
|
# Usage: GetCerbotVersionFromTag <DOCKER_VERSION>
|
|
GetCerbotVersionFromTag() {
|
|
TAG=$1
|
|
echo "${TAG//v/}"
|
|
}
|
|
|
|
# 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 and certbot version (ex. 0.35.0).
|
|
# Usage: BuildDockerCoreImage [amd64|arm32v6|arm64v8] <CERTBOT_VERSION>
|
|
BuildDockerCoreImage() {
|
|
ARCH=$1
|
|
VERSION=$2
|
|
|
|
QEMU=$(GetQemuArch "$ARCH")
|
|
docker build \
|
|
--build-arg CERTBOT_VERSION="${VERSION}" \
|
|
--build-arg TARGET_ARCH="${ARCH}" \
|
|
--build-arg QEMU_ARCH="${QEMU}" \
|
|
-f "${DOCKERFILE_PATH}" \
|
|
-t "${DOCKER_REPO}:${ARCH}-v${VERSION}" \
|
|
.
|
|
}
|
|
|
|
# Builds docker certbot plugin image for a specific architecture and certbot version (ex. 0.35.0).
|
|
# Usage: BuildDockerPluginImage [amd64|arm32v6|arm64v8] <CERTBOT_VERSION> <PLUGIN_NAME>
|
|
BuildDockerPluginImage() {
|
|
ARCH=$1
|
|
VERSION=$2
|
|
PLUGIN=$3
|
|
|
|
QEMU=$(GetQemuArch "$ARCH")
|
|
docker build \
|
|
--build-arg CERTBOT_VERSION="${VERSION}" \
|
|
--build-arg TARGET_ARCH="${ARCH}" \
|
|
--build-arg QEMU_ARCH="${QEMU}" \
|
|
--build-arg PLUGIN_NAME="${PLUGIN}" \
|
|
-f "${DOCKERFILE_PATH}" \
|
|
-t "${DOCKER_REPO}:${ARCH}-v${VERSION}" \
|
|
.
|
|
}
|
|
|
|
# Pushes docker image for a specific architecture and certbot version (ex. 0.35.0).
|
|
# Usage: BuildDockerCoreImage [amd64|arm32v6|arm64v8] <CERTBOT_VERSION>
|
|
PushDockerImage() {
|
|
ARCH=$1
|
|
VERSION=$2
|
|
|
|
docker push "${DOCKER_REPO}:${ARCH}-v${VERSION}"
|
|
}
|
|
|
|
# Creates docker image "latest" tag for a specific architecture and certbot version.
|
|
# In case of default architecture, it also creates tags without architecture part.
|
|
# As an example, for version 0.35.0 in amd64 (default arquitecture):
|
|
# - certbot/certbot:v0.35.0
|
|
# - certbot/certbot:latest
|
|
# - certbot/certbot:amd64-latest
|
|
# For version 0.35.0 in arm32v6:
|
|
# - certbot/certbot:arm32v6-latest
|
|
# Usage: TagDockerImageAliases [amd64|arm32v6|arm64v8] <CERTBOT_VERSION>
|
|
TagDockerImageAliases() {
|
|
ARCH=$1
|
|
VERSION=$2
|
|
|
|
docker tag "${DOCKER_REPO}:${ARCH}-v${VERSION}" "${DOCKER_REPO}:${ARCH}-latest"
|
|
if [ "${ARCH}" == "${DEFAULT_ARCH}" ]; then
|
|
docker tag "${DOCKER_REPO}:${ARCH}-v${VERSION}" "${DOCKER_REPO}:v${VERSION}"
|
|
docker tag "${DOCKER_REPO}:${ARCH}-v${VERSION}" "${DOCKER_REPO}:latest"
|
|
fi
|
|
}
|
|
|
|
# Pushes docker "latest" image for a specific architecture and certbot version.
|
|
# In case of default architecture, it also pushes image without architecture part.
|
|
# As an example, for version 0.35.0 in amd64 (default arquitecture):
|
|
# - certbot/certbot:v0.35.0
|
|
# - certbot/certbot:latest
|
|
# - certbot/certbot:amd64-latest
|
|
# For version 0.35.0 in arm32v6:
|
|
# - certbot/certbot:arm32v6-latest
|
|
# Usage: PushDockerImageAliases [amd64|arm32v6|arm64v8] <CERTBOT_VERSION>
|
|
PushDockerImageAliases() {
|
|
ARCH=$1
|
|
VERSION=$2
|
|
|
|
docker push "${DOCKER_REPO}:${ARCH}-latest"
|
|
if [ "${ARCH}" == "${DEFAULT_ARCH}" ]; then
|
|
docker push "${DOCKER_REPO}:v${VERSION}"
|
|
docker push "${DOCKER_REPO}:latest"
|
|
fi
|
|
}
|