Skip to content

Commit

Permalink
Merge pull request #35 from muselab-d2x/jlantz/fix-docker-build
Browse files Browse the repository at this point in the history
Fix the Docker build by porting to salesforce-cli
  • Loading branch information
jlantz authored Oct 30, 2024
2 parents ca03c4e + d1d1915 commit f4a17d7
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
platform: [linux/amd64, linux/arm64]
steps:
- name: Checkout repository

uses: actions/checkout@v4

- name: Set up QEMU
Expand All @@ -24,6 +25,7 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3


- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
Expand All @@ -36,6 +38,7 @@ jobs:
if [ "${{ github.ref_name }}" == "main" ]; then
echo "IMAGE_TAG=latest" >> $GITHUB_ENV
else
echo "IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
fi
Expand Down Expand Up @@ -67,7 +70,9 @@ jobs:
if [ "${{ github.ref_name }}" == "main" ]; then
echo "IMAGE_TAG=latest" >> $GITHUB_ENV
else
echo "IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
fi
- name: Create and push multi-arch manifests
Expand Down
91 changes: 91 additions & 0 deletions .github/workflows/docker/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Build Multi-Arch Docker Images

on:
push:
branches:
- main
- cumulusci-next**
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
target: [no-browser, browser]
platform: [linux/amd64, linux/arm64]
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set environment variables
run: |
if [ "${{ github.ref_name }}" == "main" ]; then
echo "IMAGE_TAG=latest" >> $GITHUB_ENV
else
IMAGE_TAG=$(echo "${{ github.ref_name }}" | sed -e 's/\//-/g')
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
fi
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: ${{ github.event_name == 'push' }}
tags: |
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}${{ matrix.target == 'browser' && '-browser' || '' }}${{ matrix.platform == 'linux/arm64' && '-arm64' || '' }}
platforms: ${{ matrix.platform }}
target: ${{ matrix.target }}
cache-from: type=gha
cache-to: type=gha,mode=max

merge-manifests:
needs: build
runs-on: ubuntu-latest
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set environment variables
run: |
if [ "${{ github.ref_name }}" == "main" ]; then
echo "IMAGE_TAG=latest" >> $GITHUB_ENV
else
echo "IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
fi
- name: Create and push multi-arch manifests
run: |
# For no-browser
docker buildx imagetools create -t ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }} \
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }} \
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}-arm64
# For browser
docker buildx imagetools create -t ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}-browser \
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}-browser \
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}-browser-arm64
- name: Inspect manifests
run: |
echo "Inspecting no-browser manifest:"
docker buildx imagetools inspect ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
echo "Inspecting browser manifest:"
docker buildx imagetools inspect ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}-browser

0 comments on commit f4a17d7

Please sign in to comment.