Skip to content

Commit

Permalink
DEV: Build base images for ARM64 platform in a seperate daily job
Browse files Browse the repository at this point in the history
Why this change?

We're currently building a base image for arm64 platforms as part of the
CI workflow. However, building it on Github action via emulation is too
slow and makes it meaningless to include as part of the CI workflow.

What does this change do?

This change moves the building of the bage image targeting the arm64
platform completely to a scheduled job that runs outside of the normal
CI workflow. This will also enable us to build the images for the test
and dev environment eventually as part of the workflow which we intend
to do in a follow up commit.
  • Loading branch information
tgxworld committed Oct 16, 2023
1 parent 0c93b22 commit 5709044
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 35 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/arm64-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
on:
pull_request:
schedule:
- cron: "0 0 * * *"

concurrency:
group: build-arm64-${{ format('{0}-{1}', github.head_ref || github.run_number, github.job) }}
cancel-in-progress: true

env:
BUILDKIT_PROGRESS: plain

jobs:
base:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: build slim image
run: |
cd image && ruby auto_build.rb base_slim_arm64
- name: tag slim images
id: tag-images
run: |
TAG=`date +%Y%m%d-%H%M`
echo "tag=$(echo $TAG)" >> $GITHUB_OUTPUT
docker tag discourse/base:build_slim_arm64 discourse/base:2.0.$TAG-slim-arm64
docker tag discourse/base:build_slim_arm64 discourse/base:slim-arm64
- name: build release image
run: |
cd image && ruby auto_build.rb base_arm64
- name: tag release images
run: |
TAG=${{ steps.tag-images.outputs.tag }}
docker tag discourse/base:build_arm64 discourse/base:2.0.$TAG-arm64
docker tag discourse/base:build_arm64 discourse/base:release-arm64
- name: build test_build image
run: |
cd image && ruby auto_build.rb discourse_test_build_arm64
- name: run specs
run: |
docker run --rm -e RUBY_ONLY=1 -e USE_TURBO=1 -e SKIP_PLUGINS=1 -e SKIP_LINT=1 discourse/discourse_test:build_arm64
- name: Print summary
run: |
docker images discourse/base
- name: push to dockerhub
if: success() && (github.ref == 'refs/heads/main')
env:
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
run: |
TAG=${{ steps.tag-images.outputs.tag }}
docker login --username discoursebuild --password $DOCKERHUB_PASSWORD
docker push discourse/base:2.0.$TAG-slim-arm64
docker push discourse/base:slim-arm64
docker tag discourse/base:slim-arm64 discourse/base:aarch64
docker push discourse/base:2.0.$TAG-arm64
docker push discourse/base:release-arm64
docker push discourse/base:aarch64
36 changes: 1 addition & 35 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
- main
pull_request:
schedule:
- cron: '0 0 * * *'
- cron: "0 0 * * *"

concurrency:
group: build-${{ format('{0}-{1}', github.head_ref || github.run_number, github.job) }}
Expand Down Expand Up @@ -119,37 +119,3 @@ jobs:
docker tag discourse/discourse_dev:build discourse/discourse_dev:release
docker login --username discoursebuild --password $DOCKERHUB_PASSWORD
docker push discourse/discourse_dev:release
aarch64:
runs-on: ubuntu-latest
needs: base
services:
registry:
image: registry
ports:
- 5000:5000
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: build slim image
run: |
cd image && ruby auto_build.rb base_slim_arm64
docker tag discourse/base:aarch64-slim localhost:5000/discourse/base:build_slim_arm64
- name: tag slim image as release
working-directory: image/base
run: |
docker tag discourse/base:aarch64-slim discourse/base:aarch64
- name: Print summary
run: docker images discourse/base
- name: push to dockerhub
if: success() && (github.ref == 'refs/heads/main')
env:
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
run: |
docker login --username discoursebuild --password $DOCKERHUB_PASSWORD
docker push discourse/base:aarch64
15 changes: 15 additions & 0 deletions image/auto_build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,29 @@
tag: "discourse/base:build",
extra_args: "-f release.Dockerfile",
},
base_arm64: {
name: "base",
tag: "discourse/base:build_arm64",
extra_args: "-f release.Dockerfile --platform linux/arm64",
},
discourse_test_build: {
name: "discourse_test",
tag: "discourse/discourse_test:build",
},
discourse_test_build_arm64: {
name: "discourse_test",
tag: "discourse/discourse_test:build_arm64",
extra_args: "--platform linux/arm64",
},
discourse_dev: {
name: "discourse_dev",
tag: "discourse/discourse_dev:build",
},
discourse_dev_arm64: {
name: "discourse_dev",
tag: "discourse/discourse_dev:build_arm64",
extra_args: "--platform linux/arm64",
},
}

def run(command)
Expand Down

0 comments on commit 5709044

Please sign in to comment.