Skip to content

Commit

Permalink
feat: add manifest for both amd64 and arm64 to exist in a single imag…
Browse files Browse the repository at this point in the history
…e tag
  • Loading branch information
favilo committed Sep 13, 2024
1 parent 98c5429 commit 77ea519
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 4 deletions.
25 changes: 25 additions & 0 deletions .buildkite/dev-docker/manifest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -eo pipefail

source .buildkite/retry.sh

set +x

BUILD_FROM_BRANCH=$(buildkite-agent meta-data get BUILD_FROM_BRANCH)

# login to docker registry
DOCKER_PASSWORD=$(vault read -field token /secret/ci/elastic-rally/release/docker-hub-rally)
retry 5 docker login -u elasticmachine -p $DOCKER_PASSWORD
unset DOCKER_PASSWORD

set -x
export TERM=dumb
export LC_ALL=en_US.UTF-8
./build-dev-docker-manifest.sh "$BUILD_FROM_BRANCH"

popd
popd
rm -rf "$tmp_dir"


10 changes: 8 additions & 2 deletions .buildkite/dev-docker/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@ steps:
- wait
- label: ":docker: Build Docker Artifacts for Rally amd64"
command: bash .buildkite/dev-docker/run.sh amd64
# Run on GCP to use `docker`
key: "amd64"
agents:
machineType: "n2-standard-8"
image: family/core-ubuntu-2204
- label: ":docker: Build Docker Artifacts for Rally arm64"
command: bash .buildkite/dev-docker/run.sh arm64
# Run on GCP to use `docker`
key: "arm64"
agents:
machineType: "t2a-standard-8"
image: family/core-ubuntu-2204-aarch64
- label: ":docker: build docker manifest"
command: bash .buildkite/dev-docker/manifest.sh
key: "manifest"
depends_on:
- "amd64"
- "arm64"
2 changes: 0 additions & 2 deletions .buildkite/dev-docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ git checkout "${BUILD_FROM_BRANCH}"
git --no-pager show

set -x
# FIXME: remove this if we can figure out current git branch
buildkite-agent meta-data keys
export TERM=dumb
export LC_ALL=en_US.UTF-8
./build-dev-docker.sh "$BUILD_FROM_BRANCH" "$ARCH"
Expand Down
81 changes: 81 additions & 0 deletions build-dev-docker-manifest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/usr/bin/env bash

# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# Prerequisites for releasing:

# Logged in on Docker Hub (docker login)

# fail this script immediately if any command fails with a non-zero exit code
set -eu -eE -o functrace

function push_failed {
echo "Error while pushing Docker image. Did you \`docker login\`?"
}

if [[ $# -eq 0 ]] ; then
echo "ERROR: $0 requires the Rally version to push as a command line argument and you didn't supply it."
echo "For example: $0 master"
exit 1
fi
export RALLY_BRANCH=$1
export RALLY_LICENSE=$(awk 'FNR>=2 && FNR<=2' LICENSE | sed 's/^[ \t]*//')

export GIT_SHA=$(git rev-parse --short HEAD)
export DATE=$(date +%Y%m%d)

export RALLY_VERSION="${RALLY_BRANCH}-${GIT_SHA}-${DATE}"
export MAIN_BRANCH=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p')

if [[ $RALLY_BRANCH == $MAIN_BRANCH ]]; then
export DOCKER_TAG_LATEST="dev-latest"
else
export DOCKER_TAG_LATEST="${RALLY_BRANCH}-latest"
fi

echo "========================================================"
echo "Pulling Docker images for Rally $RALLY_VERSION "
echo "========================================================"

docker pull elastic/rally:${RALLY_VERSION}-amd64
docker pull elastic/rally:${RALLY_VERSION}-arm64

echo "======================================================="
echo "Creating Docker manifest image for Rally $RALLY_VERSION"
echo "======================================================="

docker manifest create elastic/rally:${RALLY_VERSION} \
--amend elastic/rally:${RALLY_VERSION}-amd64 \
--amend elastic/rally:${RALLY_VERSION}-arm64
docker manifest push elastic/rally:${RALLY_VERSION}

echo "======================================================="
echo "Publishing Docker image elastic/rally:$RALLY_VERSION "
echo "======================================================="

trap push_failed ERR
docker push elastic/rally:${RALLY_VERSION}

echo "============================================"
echo "Publishing Docker image elastic/rally:latest"
echo "============================================"

docker tag elastic/rally:${RALLY_VERSION} elastic/rally:${DOCKER_TAG_LATEST}
docker push elastic/rally:${DOCKER_TAG_LATEST}

trap - ERR

0 comments on commit 77ea519

Please sign in to comment.