feat(docker): add arm64 images #356
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI and Docker Deploy | |
on: | |
push: | |
branches: ['main', 'dev', 'staging'] | |
tags: ['v*.*.*'] | |
pull_request: | |
branches: ['main', 'dev', 'staging'] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
# github.repository as <account>/<repo> | |
IMAGE_NAME: mnestix-browser | |
# Update the version manually | |
IMAGE_TAG_VERSION: 1.3.3 | |
jobs: | |
build-browser-image: | |
name: Build browser image | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build image | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: linux/amd64 | |
context: '.' | |
cache-to: type=gha,scope=amd64,mode=max | |
target: production | |
push: false | |
tags: mnestix/mnestix-browser:latest | |
load: true | |
- name: Save mnestix-browser image | |
run: docker save mnestix/mnestix-browser:latest -o mnestix-browser.tar | |
- name: Upload mnestix-browser artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
retention-days: 1 | |
name: mnestix-browser | |
path: mnestix-browser.tar | |
e2e-tests: | |
name: e2e test matrix | |
runs-on: ubuntu-latest | |
needs: ['build-browser-image'] | |
permissions: | |
contents: read | |
strategy: | |
fail-fast: false | |
matrix: | |
# add more containers to run more tests in parallel | |
containers: [1, 2, 3, 4] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Download mnestix-browser artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: mnestix-browser | |
# image too big to be reused | |
- name: Build test image | |
run: docker compose -f compose.yml -f docker-compose/compose.test.yml --profile tests build cypress-test | |
- name: Pull images | |
run: docker compose -f compose.yml -f docker-compose/compose.test.yml --profile tests pull | |
# overwrite the pulled image with the new image | |
- name: Load mnestix-browser image | |
run: docker load -i mnestix-browser.tar | |
- name: Run e2e tests | |
timeout-minutes: 18 | |
run: | | |
docker compose -f compose.yml -f docker-compose/compose.test.yml --profile tests up -d && | |
docker compose -f compose.yml -f docker-compose/compose.test.yml attach cypress-test | |
env: | |
SPLIT: ${{ strategy.job-total }} | |
SPLIT_INDEX: ${{ strategy.job-index }} | |
TEST_ADMIN_USER_PASSWORD: ${{ secrets.TEST_ADMIN_USER_PASSWORD }} | |
TEST_USER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }} | |
- name: E2E test collect artifact | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cypress-artifacts-${{ matrix.containers }} | |
path: cypress-artifacts/ | |
unit-tests: | |
name: Unit Tests | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: yarn install | |
- name: Run unit tests | |
run: npx jest | |
# Target for PR Merge Check | |
ci-success: | |
name: Successful build and tests | |
runs-on: ubuntu-latest | |
needs: ['unit-tests', 'e2e-tests'] | |
steps: | |
- name: Success | |
run: echo "Success" | |
# It takes 22 minutes to build the arm64 image in amd64-QEMU so we build a cache on the arm64 runner | |
# Github Issues point to a yarn problem | |
# https://github.com/docker/build-push-action/issues/471 | |
# https://github.com/nodejs/docker-node/issues/1335 | |
build-arm-cache: | |
name: Build arm image cache | |
runs-on: ubuntu-24.04-arm | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: linux/arm64 | |
context: '.' | |
cache-to: type=gha,scope=arm64,mode=max | |
target: production | |
push: false | |
push-image: | |
name: Push image to registry | |
needs: ['ci-success', 'build-arm-cache'] | |
runs-on: ubuntu-latest | |
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/dev') | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Extract branch name | |
id: extract_branch | |
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT | |
- name: Build and push docker images | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
context: '.' | |
cache-from: | | |
type=gha,scope=amd64 | |
type=gha,scope=arm64 | |
target: production | |
push: true | |
tags: | | |
${{ github.ref == 'refs/heads/main' && format('mnestix/{0}:{1}', env.IMAGE_NAME, env.IMAGE_TAG_VERSION) || '' }} | |
${{ github.ref == 'refs/heads/main' && format('mnestix/{0}:latest', env.IMAGE_NAME) || '' }} | |
${{ github.ref != 'refs/heads/main' && format('mnestix/{0}:{1}', env.IMAGE_NAME, steps.extract_branch.outputs.branch) || '' }} |