Skip to content

Commit e285f04

Browse files
Merge pull request #13192 from rabbitmq/mergify/bp/v4.0.x/pr-13160
Simplified OCI builds (backport #13160)
2 parents 9b1dc24 + c4b18c8 commit e285f04

File tree

2 files changed

+62
-375
lines changed

2 files changed

+62
-375
lines changed

.github/workflows/oci-make.yaml

Lines changed: 42 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# https://github.com/marketplace/actions/build-and-push-docker-images
1+
# When changing the OTP version, make sure to update all references:
2+
# - the default in workflow_dispatch
3+
# - otp_version in both jobs
4+
#
5+
#
26
name: OCI (make)
37
on:
48
push:
@@ -9,13 +13,28 @@ on:
913
- '.github/workflows/release-alphas.yaml'
1014
- '*.md'
1115
workflow_dispatch:
16+
inputs:
17+
otp_version:
18+
# a tag of the erlang image, see https://hub.docker.com/_/erlang for available tags
19+
# also used in the setup-beam step (same tag should work for both)
20+
description: OTP version (eg. `26`, `26.2.5.6`)
21+
default: 27
22+
build_arm:
23+
description: Build for ARM64 as well?
24+
type: boolean
25+
default: false
1226
env:
1327
REGISTRY_IMAGE: pivotalrabbitmq/rabbitmq
28+
VERSION: 4.0.0+${{ github.sha }}
1429
concurrency:
1530
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
1631
cancel-in-progress: true
1732
jobs:
1833
build-package-generic-unix:
34+
strategy:
35+
matrix:
36+
otp_version:
37+
- ${{ github.event.inputs.otp_version || '27' }}
1938
runs-on: ubuntu-latest
2039
outputs:
2140
authorized: ${{ steps.authorized.outputs.authorized }}
@@ -35,43 +54,35 @@ jobs:
3554
if: steps.authorized.outputs.authorized == 'true'
3655
uses: erlef/setup-beam@v1
3756
with:
38-
otp-version: 26.2
39-
elixir-version: 1.15
57+
otp-version: ${{ matrix.otp_version }}
58+
elixir-version: latest
4059
- name: make package-generic-unix
4160
if: steps.authorized.outputs.authorized == 'true'
4261
run: |
43-
make package-generic-unix PROJECT_VERSION=4.0.0
62+
make package-generic-unix PROJECT_VERSION=${{ env.VERSION }}
4463
- name: Upload package-generic-unix
4564
if: steps.authorized.outputs.authorized == 'true'
46-
uses: actions/upload-artifact@v4.3.1
65+
uses: actions/upload-artifact@v4
4766
with:
48-
name: package-generic-unix
67+
name: package-generic-unix-otp${{ matrix.otp_version }}
4968
path: PACKAGES/rabbitmq-server-*.tar.xz
5069

51-
build:
52-
needs: build-package-generic-unix
53-
runs-on: ubuntu-latest
54-
if: ${{ needs.build-package-generic-unix.outputs.authorized }} == 'true'
70+
build-and-push:
5571
strategy:
5672
fail-fast: false
5773
matrix:
58-
platform:
59-
- linux/amd64
60-
# Unfortunately even with type=gha cache, OpenSSL and OTP
61-
# are rebuilt often and it takes ~90 minutes to do that
62-
# in the emulated ARM mode. Disabling until we have a better solution.
63-
#- linux/arm64
74+
otp_version:
75+
- ${{ github.event.inputs.otp_version || '27' }}
76+
needs: build-package-generic-unix
77+
runs-on: ubuntu-latest
78+
if: ${{ needs.build-package-generic-unix.outputs.authorized }} == 'true'
6479
steps:
65-
- name: Prepare
66-
run: |
67-
platform=${{ matrix.platform }}
68-
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
6980
- name: Checkout
7081
uses: actions/checkout@v4
7182
- name: Download package-generic-unix
7283
uses: actions/download-artifact@v4
7384
with:
74-
name: package-generic-unix
85+
name: package-generic-unix-otp${{ matrix.otp_version }}
7586
path: PACKAGES
7687
- name: Rename package-generic-unix
7788
run: |
@@ -83,6 +94,8 @@ jobs:
8394
uses: docker/metadata-action@v5
8495
with:
8596
images: ${{ env.REGISTRY_IMAGE }}
97+
flavor: |
98+
suffix=-otp${{ matrix.otp_version }}
8699
tags: |
87100
type=ref,event=branch
88101
type=ref,event=pr
@@ -91,12 +104,6 @@ jobs:
91104
uses: docker/setup-qemu-action@v3
92105
- name: Set up Docker Buildx
93106
uses: docker/setup-buildx-action@v3
94-
- name: Login to GitHub Container Registry
95-
uses: docker/login-action@v3
96-
with:
97-
registry: ghcr.io
98-
username: ${{ github.actor }}
99-
password: ${{ secrets.GITHUB_TOKEN }}
100107
- name: Login to Docker Hub
101108
uses: docker/login-action@v3
102109
with:
@@ -106,71 +113,12 @@ jobs:
106113
id: build
107114
uses: docker/build-push-action@v6
108115
with:
116+
push: true
109117
context: packaging/docker-image
110-
platforms: ${{ matrix.platform }}
111-
labels: ${{ steps.meta.outputs.labels }}
112-
cache-to: type=gha
113-
cache-from: type=gha
114-
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
115-
- name: Export digest
116-
run: |
117-
mkdir -p /tmp/digests
118-
digest="${{ steps.build.outputs.digest }}"
119-
touch "/tmp/digests/${digest#sha256:}"
120-
- name: Upload digest
121-
uses: actions/upload-artifact@v4
122-
with:
123-
name: digests-${{ env.PLATFORM_PAIR }}
124-
path: /tmp/digests/*
125-
if-no-files-found: error
126-
retention-days: 1
127-
128-
merge:
129-
needs:
130-
- build
131-
runs-on: ubuntu-latest
132-
if: ${{ needs.build-package-generic-unix.outputs.authorized }} == 'true'
133-
steps:
134-
- name: Download digests
135-
uses: actions/download-artifact@v4
136-
with:
137-
path: /tmp/digests
138-
pattern: digests-*
139-
merge-multiple: true
140-
- name: Set up Docker Buildx
141-
uses: docker/setup-buildx-action@v3
142-
- name: Docker meta
143-
id: meta
144-
uses: docker/metadata-action@v5
145-
with:
146-
images: ${{ env.REGISTRY_IMAGE }}
147-
tags: |
148-
type=ref,event=branch
149-
type=ref,event=pr
150-
type=sha,format=long
151-
- name: Login to Docker Hub
152-
uses: docker/login-action@v3
153-
with:
154-
username: ${{ secrets.DOCKERHUB_USERNAME }}
155-
password: ${{ secrets.DOCKERHUB_PASSWORD }}
156-
- name: Create manifest list and push
157-
working-directory: /tmp/digests
158-
run: |
159-
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
160-
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
161-
- name: Inspect image
162-
run: |
163-
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
164-
165-
summary-oci:
166-
needs:
167-
- build-package-generic-unix
168-
- build
169-
- merge
170-
runs-on: ubuntu-latest
171-
steps:
172-
- name: SUMMARY
173-
run: |
174-
cat << 'EOF' | jq -e 'map(.result == "success") | all(.)'
175-
${{ toJson(needs) }}
176-
EOF
118+
platforms: ${{ github.event.inputs.build_arm && 'linux/amd64, linux/arm64' || 'linux/amd64' }}
119+
tags: ${{ steps.meta.outputs.tags }}
120+
cache-to: type=gha,mode=max,scope=${{ matrix.otp_version }}
121+
cache-from: type=gha,scope=${{ matrix.otp_version }}
122+
build-args: |
123+
OTP_VERSION=${{ matrix.otp_version }}
124+
RABBITMQ_VERSION=${{ env.VERSION }}

0 commit comments

Comments
 (0)