feat: switch to native arm64 runners for docker ce images (#10789)
Emulated docker arm64 builds are failing for community images. This PR - Switches gh action to use native arm64 runners - Merges amd64 and arm64 images to create a multi-arch docker image Fixes https://github.com/chatwoot/chatwoot/issues/10790
This commit is contained in:
118
.github/workflows/publish_foss_docker.yml
vendored
118
.github/workflows/publish_foss_docker.yml
vendored
@@ -5,6 +5,7 @@
|
|||||||
# #
|
# #
|
||||||
|
|
||||||
name: Publish Chatwoot CE docker images
|
name: Publish Chatwoot CE docker images
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
@@ -12,23 +13,32 @@ on:
|
|||||||
- master
|
- master
|
||||||
tags:
|
tags:
|
||||||
- v*
|
- v*
|
||||||
# pull_request:
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
DOCKER_REPO: chatwoot/chatwoot
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- platform: linux/amd64
|
||||||
|
runner: ubuntu-latest
|
||||||
|
- platform: linux/arm64
|
||||||
|
runner: ubuntu-22.04-arm
|
||||||
|
runs-on: ${{ matrix.runner }}
|
||||||
env:
|
env:
|
||||||
GIT_REF: ${{ github.head_ref || github.ref_name }} # ref_name to get tags/branches
|
GIT_REF: ${{ github.head_ref || github.ref_name }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Prepare
|
||||||
uses: docker/setup-qemu-action@v1
|
run: |
|
||||||
|
platform=${{ matrix.platform }}
|
||||||
- name: Set up Docker Buildx
|
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
|
|
||||||
- name: Strip enterprise code
|
- name: Strip enterprise code
|
||||||
run: |
|
run: |
|
||||||
@@ -39,29 +49,97 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo -en '\nENV CW_EDITION="ce"' >> docker/Dockerfile
|
echo -en '\nENV CW_EDITION="ce"' >> docker/Dockerfile
|
||||||
|
|
||||||
- name: set docker tag
|
- name: Set Docker Tags
|
||||||
run: |
|
run: |
|
||||||
# Replace forward slashes with hyphens in the ref name
|
|
||||||
SANITIZED_REF=$(echo "$GIT_REF" | sed 's/\//-/g')
|
SANITIZED_REF=$(echo "$GIT_REF" | sed 's/\//-/g')
|
||||||
echo "DOCKER_TAG=chatwoot/chatwoot:$SANITIZED_REF-ce" >> $GITHUB_ENV
|
if [ "${{ github.ref_name }}" = "master" ]; then
|
||||||
|
echo "DOCKER_TAG=${DOCKER_REPO}:latest-ce" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "DOCKER_TAG=${DOCKER_REPO}:${SANITIZED_REF}-ce" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
|
||||||
- name: replace docker tag if master
|
- name: Set up QEMU
|
||||||
if: github.ref_name == 'master'
|
uses: docker/setup-qemu-action@v3
|
||||||
run: |
|
|
||||||
echo "DOCKER_TAG=chatwoot/chatwoot:latest-ce" >> $GITHUB_ENV
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
|
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push by digest
|
||||||
uses: docker/build-push-action@v2
|
id: build
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: docker/Dockerfile
|
file: docker/Dockerfile
|
||||||
platforms: linux/amd64, linux/arm64
|
platforms: ${{ matrix.platform }}
|
||||||
push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
|
push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
|
||||||
tags: ${{ env.DOCKER_TAG }}
|
outputs: type=image,name=${{ env.DOCKER_TAG }},push-by-digest=true,name-canonical=true,push=true
|
||||||
|
|
||||||
|
- name: Export digest
|
||||||
|
run: |
|
||||||
|
mkdir -p ${{ runner.temp }}/digests
|
||||||
|
digest="${{ steps.build.outputs.digest }}"
|
||||||
|
touch "${{ runner.temp }}/digests/${digest#sha256:}"
|
||||||
|
|
||||||
|
- name: Upload digest
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: digests-${{ env.PLATFORM_PAIR }}
|
||||||
|
path: ${{ runner.temp }}/digests/*
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
merge:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- build
|
||||||
|
steps:
|
||||||
|
- name: Download digests
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: ${{ runner.temp }}/digests
|
||||||
|
pattern: digests-*
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Create manifest list and push
|
||||||
|
working-directory: ${{ runner.temp }}/digests
|
||||||
|
env:
|
||||||
|
GIT_REF: ${{ github.head_ref || github.ref_name }}
|
||||||
|
run: |
|
||||||
|
SANITIZED_REF=$(echo "$GIT_REF" | sed 's/\//-/g')
|
||||||
|
if [ "${{ github.ref_name }}" = "master" ]; then
|
||||||
|
TAG="${DOCKER_REPO}:latest-ce"
|
||||||
|
else
|
||||||
|
TAG="${DOCKER_REPO}:${SANITIZED_REF}-ce"
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker buildx imagetools create -t $TAG \
|
||||||
|
$(printf '${{ env.DOCKER_REPO }}@sha256:%s ' *)
|
||||||
|
|
||||||
|
- name: Inspect image
|
||||||
|
env:
|
||||||
|
GIT_REF: ${{ github.head_ref || github.ref_name }}
|
||||||
|
run: |
|
||||||
|
SANITIZED_REF=$(echo "$GIT_REF" | sed 's/\//-/g')
|
||||||
|
if [ "${{ github.ref_name }}" = "master" ]; then
|
||||||
|
TAG="${DOCKER_REPO}:latest-ce"
|
||||||
|
else
|
||||||
|
TAG="${DOCKER_REPO}:${SANITIZED_REF}-ce"
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker buildx imagetools inspect $TAG
|
||||||
|
|||||||
Reference in New Issue
Block a user