Skip to content

Commit

Permalink
Merge pull request #3143 from rabbitmq/oci-matrix
Browse files Browse the repository at this point in the history
Build OCI image for each supported Erlang major version

(cherry picked from commit f46a267)
  • Loading branch information
gerhard authored and ansd committed Jun 25, 2021
1 parent 2f3987e commit 6fd38d6
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 16 deletions.
61 changes: 47 additions & 14 deletions .github/workflows/oci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,67 @@ on:
- Makefile
- plugins.mk
- rabbitmq-components.mk
- .github/workflows/oci.yaml
env:
GENERIC_UNIX_ARCHIVE: ${{ github.workspace }}/PACKAGES/rabbitmq-server-generic-unix-${{ github.sha }}.tar.xz
RABBITMQ_VERSION: ${{ github.sha }}
VERSION: ${{ github.sha }}
jobs:

# This job will build one docker image per supported Erlang major version.
# Each image will have two tags (one containing the Git commit SHA, one containing the branch name).
#
# For example, for Git commit SHA '1111aaa' and branch name 'main' and maximum supported Erlang major version '25',
# the following 3 images and 6 tags will be pushed to Dockerhub:
#
# * 1111aaa-otp-max (image OTP 25)
# * main-otp-max (image OTP 25)
# * 1111aaa-otp-max-1 (image OTP 24)
# * main-otp-max-1 (image OTP 24)
# * 1111aaa-otp-max-2 (image OTP 23)
# * main-otp-max-2 (image OTP 23)

build-publish-dev:
runs-on: ubuntu-latest
strategy:
matrix:
# Build image for every supported Erlang major version.
# Source of truth for released versions: https://www.rabbitmq.com/which-erlang.html
# For Elixir: https://github.com/rabbitmq/rabbitmq-server/blob/master/deps/rabbitmq_cli/mix.exs#L14
# As of June 2021:
otp: ['24.0.2', '23.2.1']
include:
- otp: '24.0.2'
otp_sha256: 4abca2cda7fc962ad65575e5ed834dd69c745e7e637f92cfd49f384a281d0f18
elixir: '1.12.1'
image_tag_suffix: '-otp-max'
- otp: '23.2.1'
otp_sha256: e7034e2cfe50d7570ac8f70ea7ba69ea013f10863043e25132f0a5d3d0d8d3a7
elixir: '1.11.4'
image_tag_suffix: '-otp-max-1'
env:
IMAGE_TAG_1: ${{ github.sha }}${{ matrix.image_tag_suffix }}
steps:
- name: Checkout
uses: actions/checkout@v2

# RabbitMQ master supports Erlang 24 (correct at June 2021)
# Source of truth for released versions: https://www.rabbitmq.com/which-erlang.html
#
# For Elixir: https://github.com/rabbitmq/rabbitmq-server/blob/master/deps/rabbitmq_cli/mix.exs#L14
- name: Set up max supported Erlang & Elixir
- name: Set up Erlang & Elixir
uses: erlef/setup-beam@v1.7
with:
otp-version: '24.0.2'
elixir-version: '1.12.1'
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}

- name: Build generic unix package
run: |
make package-generic-unix PROJECT_VERSION=${GITHUB_SHA}
- name: Build container image
working-directory: packaging/docker-image
run: >-
make dist
IMAGE_TAG=${GITHUB_REF##*/}
SKIP_PGP_VERIFY=true
OTP_VERSION=24.0.2
OTP_SHA256=4abca2cda7fc962ad65575e5ed834dd69c745e7e637f92cfd49f384a281d0f18
env:
OTP_VERSION: ${{ matrix.otp }}
OTP_SHA256: ${{ matrix.otp_sha256 }}
run: |
make dist SKIP_PGP_VERIFY=true
- name: Login to DockerHub
working-directory: packaging/docker-image
Expand All @@ -51,7 +79,12 @@ jobs:
--username '${{ secrets.DOCKERHUB_USERNAME }}' \
--password '${{ secrets.DOCKERHUB_PASSWORD }}'
# Push the same image with two different tags:
# 1. <git_commit_sha>-otp-max[-1|-2]
# 2. <branch_name>-otp-max[-1|-2]
- name: Push container image to DockerHub
working-directory: packaging/docker-image
env:
IMAGE_TAG_SUFFIX: ${{ matrix.image_tag_suffix }}
run: |
make push
make push IMAGE_TAG_2=${GITHUB_REF##*/}${IMAGE_TAG_SUFFIX}
9 changes: 7 additions & 2 deletions packaging/docker-image/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ SKIP_PGP_VERIFY ?= false
PGP_KEYSERVER ?= pgpkeys.eu
ALT1_PGP_KEYSERVER ?= keyserver.ubuntu.com
ALT2_PGP_KEYSERVER ?= pgpkeys.uk
IMAGE_TAG_1 ?= $(subst +,-,$(VERSION))

all: dist

Expand All @@ -50,11 +51,15 @@ dist:
--build-arg OTP_VERSION=$(OTP_VERSION) \
--build-arg OTP_SHA256=$(OTP_SHA256) \
--build-arg RABBITMQ_BUILD=rabbitmq_server-$(VERSION) \
--tag pivotalrabbitmq/rabbitmq:$(subst +,-,$(VERSION)) \
--tag $(REPO):$(IMAGE_TAG_1) \
.

push:
docker push pivotalrabbitmq/rabbitmq:$(subst +,-,$(VERSION))
docker push $(REPO):$(IMAGE_TAG_1)
ifdef IMAGE_TAG_2
docker tag $(REPO):$(IMAGE_TAG_1) $(REPO):$(IMAGE_TAG_2)
docker push $(REPO):$(IMAGE_TAG_2)
endif

clean:
rm -rf rabbitmq_server-*

0 comments on commit 6fd38d6

Please sign in to comment.