certbot/tools/docker/deploy.sh

73 lines
2.9 KiB
Bash
Raw Normal View History

#!/bin/bash
Automate Docker builds in Azure (#8193) 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>
2020-08-11 16:09:38 -04:00
set -euxo pipefail
IFS=$'\n\t'
Automate Docker builds in Azure (#8193) 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>
2020-08-11 16:09:38 -04:00
# This script deploys new versions of Certbot and Certbot plugin docker images.
Docker build improvements (#8218) Fixes https://github.com/certbot/certbot/issues/8208. Fixes https://github.com/certbot/certbot/issues/8198. In addition to those two linked issues, this PR: * Splits both the build and deploy steps based on architecture for performance. The Docker builds should no longer be the bottleneck in any stage of the pipeline. * Skips building Docker images for ARM on `test-` branches like [we do for snaps](https://github.com/certbot/certbot/blob/e8a232297d6faedb3b0bffc197a2e98c2e59edcb/.azure-pipelines/templates/jobs/packaging-jobs.yml#L67-L71). I initially didn't want to do this, but the ARM builds take ~18 minutes which is significantly longer than any other job currently running on our `test-` branches. You can see tests running on my fork at: * [Release pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=387&view=results) * [Test pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=388&view=results) * [Nightly pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=390&view=results) * update script intro * update readme * ParseRequestedArch * build all arch in Azure * Build docker images during testing/packaging. * require global variable? * Error if TAG_BASE is empty. * prepare build job * change variable syntax * Update deploy stage. * remove old dockerTag param * add displayName * fix docker images command * split docker_build by arch * Allow deploying a subset of architectures. * deploy in parallel * Skip ARM builds on test- branches. * fix spacing
2020-08-18 13:48:01 -04:00
# Usage: ./deploy.sh [TAG] [all|amd64|arm32v6|arm64v8]
# with the [TAG] value corresponding the base of the tag to give the Docker
# images and the 2nd value being the architecture to build snaps for.
Automate Docker builds in Azure (#8193) 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>
2020-08-11 16:09:38 -04:00
# Values should be something like `v0.34.0` or `nightly`. The given value is
# only the base of the tag because the things like the CPU architecture are
# also added to the full tag.
WORK_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
Automate Docker builds in Azure (#8193) 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>
2020-08-11 16:09:38 -04:00
TAG_BASE="$1" # Eg. v0.35.0 or nightly
Docker build improvements (#8218) Fixes https://github.com/certbot/certbot/issues/8208. Fixes https://github.com/certbot/certbot/issues/8198. In addition to those two linked issues, this PR: * Splits both the build and deploy steps based on architecture for performance. The Docker builds should no longer be the bottleneck in any stage of the pipeline. * Skips building Docker images for ARM on `test-` branches like [we do for snaps](https://github.com/certbot/certbot/blob/e8a232297d6faedb3b0bffc197a2e98c2e59edcb/.azure-pipelines/templates/jobs/packaging-jobs.yml#L67-L71). I initially didn't want to do this, but the ARM builds take ~18 minutes which is significantly longer than any other job currently running on our `test-` branches. You can see tests running on my fork at: * [Release pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=387&view=results) * [Test pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=388&view=results) * [Nightly pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=390&view=results) * update script intro * update readme * ParseRequestedArch * build all arch in Azure * Build docker images during testing/packaging. * require global variable? * Error if TAG_BASE is empty. * prepare build job * change variable syntax * Update deploy stage. * remove old dockerTag param * add displayName * fix docker images command * split docker_build by arch * Allow deploying a subset of architectures. * deploy in parallel * Skip ARM builds on test- branches. * fix spacing
2020-08-18 13:48:01 -04:00
if [ -z "$TAG_BASE" ]; then
echo "We cannot tag Docker images with an empty string!" >&2
exit 1
fi
Automate Docker builds in Azure (#8193) 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>
2020-08-11 16:09:38 -04:00
source "$WORK_DIR/lib/common"
Docker build improvements (#8218) Fixes https://github.com/certbot/certbot/issues/8208. Fixes https://github.com/certbot/certbot/issues/8198. In addition to those two linked issues, this PR: * Splits both the build and deploy steps based on architecture for performance. The Docker builds should no longer be the bottleneck in any stage of the pipeline. * Skips building Docker images for ARM on `test-` branches like [we do for snaps](https://github.com/certbot/certbot/blob/e8a232297d6faedb3b0bffc197a2e98c2e59edcb/.azure-pipelines/templates/jobs/packaging-jobs.yml#L67-L71). I initially didn't want to do this, but the ARM builds take ~18 minutes which is significantly longer than any other job currently running on our `test-` branches. You can see tests running on my fork at: * [Release pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=387&view=results) * [Test pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=388&view=results) * [Nightly pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=390&view=results) * update script intro * update readme * ParseRequestedArch * build all arch in Azure * Build docker images during testing/packaging. * require global variable? * Error if TAG_BASE is empty. * prepare build job * change variable syntax * Update deploy stage. * remove old dockerTag param * add displayName * fix docker images command * split docker_build by arch * Allow deploying a subset of architectures. * deploy in parallel * Skip ARM builds on test- branches. * fix spacing
2020-08-18 13:48:01 -04:00
ParseRequestedArch "${2}"
Docker build improvements (#8218) Fixes https://github.com/certbot/certbot/issues/8208. Fixes https://github.com/certbot/certbot/issues/8198. In addition to those two linked issues, this PR: * Splits both the build and deploy steps based on architecture for performance. The Docker builds should no longer be the bottleneck in any stage of the pipeline. * Skips building Docker images for ARM on `test-` branches like [we do for snaps](https://github.com/certbot/certbot/blob/e8a232297d6faedb3b0bffc197a2e98c2e59edcb/.azure-pipelines/templates/jobs/packaging-jobs.yml#L67-L71). I initially didn't want to do this, but the ARM builds take ~18 minutes which is significantly longer than any other job currently running on our `test-` branches. You can see tests running on my fork at: * [Release pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=387&view=results) * [Test pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=388&view=results) * [Nightly pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=390&view=results) * update script intro * update readme * ParseRequestedArch * build all arch in Azure * Build docker images during testing/packaging. * require global variable? * Error if TAG_BASE is empty. * prepare build job * change variable syntax * Update deploy stage. * remove old dockerTag param * add displayName * fix docker images command * split docker_build by arch * Allow deploying a subset of architectures. * deploy in parallel * Skip ARM builds on test- branches. * fix spacing
2020-08-18 13:48:01 -04:00
# Creates and pushes all Docker images aliases for the requested architectures
# set in the environment variable ALL_REQUESTED_ARCH. 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.
Docker build improvements (#8218) Fixes https://github.com/certbot/certbot/issues/8208. Fixes https://github.com/certbot/certbot/issues/8198. In addition to those two linked issues, this PR: * Splits both the build and deploy steps based on architecture for performance. The Docker builds should no longer be the bottleneck in any stage of the pipeline. * Skips building Docker images for ARM on `test-` branches like [we do for snaps](https://github.com/certbot/certbot/blob/e8a232297d6faedb3b0bffc197a2e98c2e59edcb/.azure-pipelines/templates/jobs/packaging-jobs.yml#L67-L71). I initially didn't want to do this, but the ARM builds take ~18 minutes which is significantly longer than any other job currently running on our `test-` branches. You can see tests running on my fork at: * [Release pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=387&view=results) * [Test pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=388&view=results) * [Nightly pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=390&view=results) * update script intro * update readme * ParseRequestedArch * build all arch in Azure * Build docker images during testing/packaging. * require global variable? * Error if TAG_BASE is empty. * prepare build job * change variable syntax * Update deploy stage. * remove old dockerTag param * add displayName * fix docker images command * split docker_build by arch * Allow deploying a subset of architectures. * deploy in parallel * Skip ARM builds on test- branches. * fix spacing
2020-08-18 13:48:01 -04:00
# Usage: TagAndPushForAllRequestedArch [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
Docker build improvements (#8218) Fixes https://github.com/certbot/certbot/issues/8208. Fixes https://github.com/certbot/certbot/issues/8198. In addition to those two linked issues, this PR: * Splits both the build and deploy steps based on architecture for performance. The Docker builds should no longer be the bottleneck in any stage of the pipeline. * Skips building Docker images for ARM on `test-` branches like [we do for snaps](https://github.com/certbot/certbot/blob/e8a232297d6faedb3b0bffc197a2e98c2e59edcb/.azure-pipelines/templates/jobs/packaging-jobs.yml#L67-L71). I initially didn't want to do this, but the ARM builds take ~18 minutes which is significantly longer than any other job currently running on our `test-` branches. You can see tests running on my fork at: * [Release pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=387&view=results) * [Test pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=388&view=results) * [Nightly pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=390&view=results) * update script intro * update readme * ParseRequestedArch * build all arch in Azure * Build docker images during testing/packaging. * require global variable? * Error if TAG_BASE is empty. * prepare build job * change variable syntax * Update deploy stage. * remove old dockerTag param * add displayName * fix docker images command * split docker_build by arch * Allow deploying a subset of architectures. * deploy in parallel * Skip ARM builds on test- branches. * fix spacing
2020-08-18 13:48:01 -04:00
# * ALL_REQUESTED_ARCH
TagAndPushForAllRequestedArch() {
DOCKER_REPO="${DOCKER_HUB_ORG}/${1}"
Docker build improvements (#8218) Fixes https://github.com/certbot/certbot/issues/8208. Fixes https://github.com/certbot/certbot/issues/8198. In addition to those two linked issues, this PR: * Splits both the build and deploy steps based on architecture for performance. The Docker builds should no longer be the bottleneck in any stage of the pipeline. * Skips building Docker images for ARM on `test-` branches like [we do for snaps](https://github.com/certbot/certbot/blob/e8a232297d6faedb3b0bffc197a2e98c2e59edcb/.azure-pipelines/templates/jobs/packaging-jobs.yml#L67-L71). I initially didn't want to do this, but the ARM builds take ~18 minutes which is significantly longer than any other job currently running on our `test-` branches. You can see tests running on my fork at: * [Release pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=387&view=results) * [Test pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=388&view=results) * [Nightly pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=390&view=results) * update script intro * update readme * ParseRequestedArch * build all arch in Azure * Build docker images during testing/packaging. * require global variable? * Error if TAG_BASE is empty. * prepare build job * change variable syntax * Update deploy stage. * remove old dockerTag param * add displayName * fix docker images command * split docker_build by arch * Allow deploying a subset of architectures. * deploy in parallel * Skip ARM builds on test- branches. * fix spacing
2020-08-18 13:48:01 -04:00
for TARGET_ARCH in "${ALL_REQUESTED_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
}
Automate Docker builds in Azure (#8193) 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>
2020-08-11 16:09:38 -04:00
# Step 1: Certbot core Docker
Docker build improvements (#8218) Fixes https://github.com/certbot/certbot/issues/8208. Fixes https://github.com/certbot/certbot/issues/8198. In addition to those two linked issues, this PR: * Splits both the build and deploy steps based on architecture for performance. The Docker builds should no longer be the bottleneck in any stage of the pipeline. * Skips building Docker images for ARM on `test-` branches like [we do for snaps](https://github.com/certbot/certbot/blob/e8a232297d6faedb3b0bffc197a2e98c2e59edcb/.azure-pipelines/templates/jobs/packaging-jobs.yml#L67-L71). I initially didn't want to do this, but the ARM builds take ~18 minutes which is significantly longer than any other job currently running on our `test-` branches. You can see tests running on my fork at: * [Release pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=387&view=results) * [Test pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=388&view=results) * [Nightly pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=390&view=results) * update script intro * update readme * ParseRequestedArch * build all arch in Azure * Build docker images during testing/packaging. * require global variable? * Error if TAG_BASE is empty. * prepare build job * change variable syntax * Update deploy stage. * remove old dockerTag param * add displayName * fix docker images command * split docker_build by arch * Allow deploying a subset of architectures. * deploy in parallel * Skip ARM builds on test- branches. * fix spacing
2020-08-18 13:48:01 -04:00
TagAndPushForAllRequestedArch "certbot"
Automate Docker builds in Azure (#8193) 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>
2020-08-11 16:09:38 -04:00
# Step 2: Certbot DNS plugins Docker images
for plugin in "${CERTBOT_PLUGINS[@]}"; do
Docker build improvements (#8218) Fixes https://github.com/certbot/certbot/issues/8208. Fixes https://github.com/certbot/certbot/issues/8198. In addition to those two linked issues, this PR: * Splits both the build and deploy steps based on architecture for performance. The Docker builds should no longer be the bottleneck in any stage of the pipeline. * Skips building Docker images for ARM on `test-` branches like [we do for snaps](https://github.com/certbot/certbot/blob/e8a232297d6faedb3b0bffc197a2e98c2e59edcb/.azure-pipelines/templates/jobs/packaging-jobs.yml#L67-L71). I initially didn't want to do this, but the ARM builds take ~18 minutes which is significantly longer than any other job currently running on our `test-` branches. You can see tests running on my fork at: * [Release pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=387&view=results) * [Test pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=388&view=results) * [Nightly pipeline](https://dev.azure.com/bmw0523/bmw/_build/results?buildId=390&view=results) * update script intro * update readme * ParseRequestedArch * build all arch in Azure * Build docker images during testing/packaging. * require global variable? * Error if TAG_BASE is empty. * prepare build job * change variable syntax * Update deploy stage. * remove old dockerTag param * add displayName * fix docker images command * split docker_build by arch * Allow deploying a subset of architectures. * deploy in parallel * Skip ARM builds on test- branches. * fix spacing
2020-08-18 13:48:01 -04:00
TagAndPushForAllRequestedArch "${plugin}"
Automate Docker builds in Azure (#8193) 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>
2020-08-11 16:09:38 -04:00
done