Skip to content

Commit

Permalink
Merge pull request #347 from buildkite/docker-refactor
Browse files Browse the repository at this point in the history
Simplify docker release script
  • Loading branch information
yob authored Dec 5, 2024
2 parents 935385e + c7f1a26 commit e48e905
Showing 1 changed file with 1 addition and 29 deletions.
30 changes: 1 addition & 29 deletions .buildkite/steps/release-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,7 @@ rm -rf dist
mkdir -p dist
buildkite-agent artifact download --build "${BUILDKITE_TRIGGERED_FROM_BUILD_ID}" "dist/buildkite-agent-metrics-linux-*" ./dist

echo "--- Building :docker: image"

builder_name="$(docker buildx create --use)"
# shellcheck disable=SC2064 # we want the current $builder_name to be trapped, not the runtime one
trap "docker buildx rm ${builder_name} || true" EXIT

echo "--- Building :docker: ${image_tag} for all architectures"
docker buildx build \
--progress plain \
--builder "${builder_name}" \
--platform linux/amd64,linux/arm64 \
--file .buildkite/Dockerfile.public \
.

# Tag images for just the native architecture. There is a limitation in docker that prevents this
# from being done in one command. Luckliy the second build will be quick because of docker layer caching
# As this is just a native build, we don't need the lock.
docker buildx build \
--progress plain \
--builder "${builder_name}" \
--tag "${image_tag}" \
--file .buildkite/Dockerfile.public \
--load \
.

echo --- :ecr: Pushing to ECR
echo --- :ecr: Building and Pushing to ECR

# Convert 2.3.2 into [ 2.3.2 2.3 2 ] or 3.0-beta.42 in [ 3.0-beta.42 3.0 3 ]
parse_version() {
Expand All @@ -71,14 +46,11 @@ parse_version() {

version_tags=($(parse_version "${version#v}"))

# Do another build with all architectures and tags. The layers should be cached
# from the previous build with all architectures.
# Pushing to the docker registry in this way greatly simplifies creating the
# manifest list on the docker registry so that either architecture can be pulled
# with the same tag.
release_dry_run docker buildx build \
--progress plain \
--builder "${builder_name}" \
--tag "${registry}:latest" \
"${version_tags[@]/#/--tag=${registry}:v}" \
--platform linux/amd64,linux/arm64 \
Expand Down

0 comments on commit e48e905

Please sign in to comment.