Skip to content

Commit

Permalink
Faster OCI builds
Browse files Browse the repository at this point in the history
* use the official erlang image as the base
  (no more openssl and erlang recompilation)
* build with OTP26 and OTP27 (compilation is performed with the same
  OTP version that is used at runtime)
* remove a bunch of things that are not clearly needed
  • Loading branch information
mkuratczyk committed Jan 24, 2025
1 parent 4627e7a commit 0cbbac6
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 542 deletions.
179 changes: 0 additions & 179 deletions .github/workflows/oci-arm64-make.yaml

This file was deleted.

152 changes: 62 additions & 90 deletions .github/workflows/oci-make.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
name: OCI (make)
on:
push:
branches:
- fast-oci
paths-ignore:
- '.github/workflows/secondary-umbrella.yaml'
- '.github/workflows/update-elixir-patches.yaml'
Expand All @@ -10,12 +12,15 @@ on:
- '*.md'
workflow_dispatch:
env:
REGISTRY_IMAGE: pivotalrabbitmq/rabbitmq
REGISTRY_IMAGE: pivotalrabbitmq/rabbitmq-test
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build-package-generic-unix:
strategy:
matrix:
otp_version: [26, 27]
runs-on: ubuntu-latest
outputs:
authorized: ${{ steps.authorized.outputs.authorized }}
Expand All @@ -35,43 +40,34 @@ jobs:
if: steps.authorized.outputs.authorized == 'true'
uses: erlef/setup-beam@v1
with:
otp-version: 26.2
elixir-version: 1.15
otp-version: ${{ matrix.otp_version }}
elixir-version: latest
- name: make package-generic-unix
if: steps.authorized.outputs.authorized == 'true'
run: |
make package-generic-unix PROJECT_VERSION=4.1.0-alpha.1
- name: Upload package-generic-unix
if: steps.authorized.outputs.authorized == 'true'
uses: actions/upload-artifact@v4.3.1
uses: actions/upload-artifact@v4
with:
name: package-generic-unix
name: package-generic-unix-otp${{ matrix.otp_version }}
path: PACKAGES/rabbitmq-server-*.tar.xz

build:
needs: build-package-generic-unix
runs-on: ubuntu-latest
if: ${{ needs.build-package-generic-unix.outputs.authorized }} == 'true'
build-and-push:
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
# Unfortunately even with type=gha cache, OpenSSL and OTP
# are rebuilt often and it takes ~90 minutes to do that
# in the emulated ARM mode. Disabling until we have a better solution.
#- linux/arm64
otp_version: [26, 27]
needs: build-package-generic-unix
runs-on: ubuntu-latest
if: ${{ needs.build-package-generic-unix.outputs.authorized }} == 'true'
steps:
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
- name: Download package-generic-unix
uses: actions/download-artifact@v4
with:
name: package-generic-unix
name: package-generic-unix-otp${{ matrix.otp_version }}
path: PACKAGES
- name: Rename package-generic-unix
run: |
Expand All @@ -83,6 +79,8 @@ jobs:
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
flavor: |
suffix=-otp${{ matrix.otp_version }}
tags: |
type=ref,event=branch
type=ref,event=pr
Expand All @@ -91,12 +89,6 @@ jobs:
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
Expand All @@ -106,71 +98,51 @@ jobs:
id: build
uses: docker/build-push-action@v6
with:
push: true
context: packaging/docker-image
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64, linux/arm64
#labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
#tags: pivotalrabbitmq/rabbitmq-test:otp${{ matrix.otp_version }}
cache-to: type=gha
cache-from: type=gha
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
#outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
build-args:
OTP_VERSION=${{ matrix.otp_version }}

merge:
needs:
- build
runs-on: ubuntu-latest
if: ${{ needs.build-package-generic-unix.outputs.authorized }} == 'true'
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,format=long
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
summary-oci:
needs:
- build-package-generic-unix
- build
- merge
runs-on: ubuntu-latest
steps:
- name: SUMMARY
run: |
cat << 'EOF' | jq -e 'map(.result == "success") | all(.)'
${{ toJson(needs) }}
EOF
# merge:
# needs:
# - build
# runs-on: ubuntu-latest
# if: ${{ needs.build-package-generic-unix.outputs.authorized }} == 'true'
# steps:
# - name: Download digests
# uses: actions/download-artifact@v4
# with:
# path: /tmp/digests
# pattern: digests-*
# merge-multiple: true
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# - name: Docker meta
# id: meta
# uses: docker/metadata-action@v5
# with:
# images: ${{ env.REGISTRY_IMAGE }}
# tags: |
# type=ref,event=branch
# type=ref,event=pr
# type=sha,format=long
# - name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_PASSWORD }}
# - name: Create manifest list and push
# working-directory: /tmp/digests
# run: |
# docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
# $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
# - name: Inspect image
# run: |
# docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
Loading

0 comments on commit 0cbbac6

Please sign in to comment.