mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 18:01:01 -06:00
5c8ff928ba
#15596 set things up with the intent that the docker image build process would be handled by the automated build system on dockerhub, but after merging we found that it's impossible to change the source git repository for an existing dockerhub repository. To get away from the limitations of dockerhub, we intend to eventually automate these builds in a separate CI system. Here we add some scripts that would drive such an automated process. It's split into multiple steps to allow for situations where the new version should not be tagged as the latest, and to make it easier and safer to test the build script while doing development on it. Since this automated process doesn't yet exist, a wrapper script release.sh is included to help run a local, manual build and deploy process in the mean time. The README.md in the docker-release dir here contains details on the intended usage.
35 lines
1.3 KiB
Bash
Executable File
35 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# This script builds two docker images for the version referred to by the
|
|
# current git HEAD.
|
|
#
|
|
# After running this, run tag.sh if the images that are built should be
|
|
# tagged as the "latest" release.
|
|
|
|
set -eu
|
|
|
|
BASE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
cd "$BASE"
|
|
|
|
if [ "$#" -eq 0 ]; then
|
|
# We assume that this is always running while git HEAD is pointed at a release
|
|
# tag or a branch that is pointed at the same commit as a release tag. If not,
|
|
# this will fail since we can't build a release image for a commit that hasn't
|
|
# actually been released.
|
|
VERSION="$(git describe)"
|
|
else
|
|
# This mode is here only to support release.sh, which ensures that the given
|
|
# version matches the current git tag. Running this script manually with
|
|
# an argument can't guarantee correct behavior since the "full" image
|
|
# will be built against the current work tree regardless of which version
|
|
# is selected.
|
|
VERSION="$1"
|
|
fi
|
|
|
|
echo "-- Building release docker images for version $VERSION --"
|
|
echo ""
|
|
VERSION_SLUG="${VERSION#v}"
|
|
|
|
docker build --no-cache "--build-arg=TERRAFORM_VERSION=${VERSION_SLUG}" -t hashicorp/terraform:${VERSION_SLUG} -f "Dockerfile-release" .
|
|
docker build --no-cache -t "hashicorp/terraform:${VERSION_SLUG}-full" ../../
|