Skip to content

Build OSS snapshot image #5002

Build OSS snapshot image

Build OSS snapshot image #5002

name: Build OSS snapshot image
on:
workflow_dispatch:
inputs:
HZ_VERSION:
description: 'Version of Hazelcast to build the image for'
required: true
HZ_REVISION:
description: 'Commit id of Hazelcast snapshot jar'
required: true
env:
test_container_name_oss: hazelcast-oss-test
jobs:
jdks:
uses: ./.github/workflows/get-supported-jdks.yaml
push:
runs-on: ubuntu-latest
needs: jdks
strategy:
fail-fast: false
matrix:
jdk: ${{ fromJSON(needs.jdks.outputs.jdks) }}
variant: [ 'slim','' ]
include:
- variant: slim
- variant: ''
env:
DOCKER_REGISTRY: ${{ secrets.HZ_SNAPSHOT_INTERNAL_DOCKER_REGISTRY }}
DOCKER_USERNAME: ${{ secrets.JFROG_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.JFROG_PASSWORD }}
# required by OSS get_hz_dist_zip function
HZ_SNAPSHOT_INTERNAL_USERNAME: ${{ secrets.HZ_SNAPSHOT_INTERNAL_USERNAME }}
HZ_SNAPSHOT_INTERNAL_PASSWORD: ${{ secrets.HZ_SNAPSHOT_INTERNAL_PASSWORD }}
HZ_VERSION: ${{ github.event.inputs.HZ_VERSION }}
steps:
- name: Compute Suffix
run: |
if [ -n "${{ matrix.variant }}" ]; then
SUFFIX=-${{ matrix.variant }}
else
SUFFIX=
fi
echo "SUFFIX=${SUFFIX}" >> $GITHUB_ENV
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: v0.5.1
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: 'us-east-1'
- name: Get OSS dist ZIP
run: |
. .github/scripts/oss-build.functions.sh
HAZELCAST_OSS_ZIP_URL=$(get_hz_dist_zip "${{ matrix.variant }}" "${HZ_VERSION}")
curl --fail --silent --show-error --location "$HAZELCAST_OSS_ZIP_URL" --output hazelcast-oss/hazelcast-distribution.zip;
- name: Build Test OSS image
run: |
docker buildx build --load \
--build-arg JDK_VERSION=${{ matrix.jdk }} \
--tag hazelcast-oss:test \
hazelcast-oss
- name: Run smoke test against OSS image
timeout-minutes: 2
run: |
.github/scripts/simple-smoke-test.sh hazelcast-oss:test ${{ env.test_container_name_oss }} oss ${HZ_VERSION}
- name: Get docker logs
if: ${{ always() }}
run: |
DOCKER_LOG_FILE_OSS=docker-${{ env.test_container_name_oss }}${{ env.SUFFIX }}-jdk${{ matrix.jdk }}.log
echo "DOCKER_LOG_FILE_OSS=${DOCKER_LOG_FILE_OSS}" >> $GITHUB_ENV
docker logs ${{ env.test_container_name_oss }} > ${DOCKER_LOG_FILE_OSS}
- name: Store docker logs as artifact
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: docker-logs${{ env.SUFFIX }}-jdk${{ matrix.jdk }}
path: |
${{ env.DOCKER_LOG_FILE_OSS }}
- name: Login to Docker Registry
run: echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin $DOCKER_REGISTRY
- name: Build/Push OSS image
run: |
set -eEuo pipefail ${RUNNER_DEBUG:+-x}
. .github/scripts/get-tags-to-push.sh
. .github/scripts/docker.functions.sh
VERSIONS=("$HZ_VERSION")
DOCKER_DIR=hazelcast-oss
IMAGE_NAME=$DOCKER_REGISTRY/docker/hazelcast/hazelcast
DEFAULT_JDK="$(get_default_jdk $DOCKER_DIR)"
TAGS_TO_PUSH=$(augment_with_suffixed_tags "${VERSIONS[*]}" "${{ env.SUFFIX }}" "${{ matrix.jdk }}" "$DEFAULT_JDK")
echo "TAGS_TO_PUSH=$TAGS_TO_PUSH"
TAGS_ARG=""
for tag in ${TAGS_TO_PUSH[@]}
do
TAGS_ARG="${TAGS_ARG} --tag ${IMAGE_NAME}:${tag}"
done
PLATFORMS="$(get_alpine_supported_platforms "${{ matrix.jdk }}")"
docker buildx build --push \
--build-arg JDK_VERSION=${{ matrix.jdk }} \
--label hazelcast.revision=${{ github.event.inputs.HZ_REVISION }} \
$TAGS_ARG \
--platform=${PLATFORMS} $DOCKER_DIR
- name: Slack notification
uses: ./.github/actions/slack-notification
if: failure()
with:
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK }}