Skip to content

Commit

Permalink
DEV: Add job for building Discourse dev release image for arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
tgxworld committed Oct 17, 2023
1 parent 4130fea commit 38cf7e3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 9 deletions.
36 changes: 34 additions & 2 deletions .github/workflows/arm64-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ env:
jobs:
base:
runs-on: ubuntu-20.04
services:
registry:
image: registry
ports:
- 5000:5000
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -34,17 +39,19 @@ jobs:
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
docker push localhost:5000/discourse/base:build_slim_arm64
- name: build release image
run: |
cd image && ruby auto_build.rb base_arm64
cd image && ruby auto_build.rb base_arm64 --build-arg from=localhost:5000/discourse/base
- 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
docker push localhost:5000/discourse/base:build_arm64
- name: build test_build image
run: |
cd image && ruby auto_build.rb discourse_test_build_arm64
cd image && ruby auto_build.rb discourse_test_build_arm64 --build-arg from=localhost:5000/discourse/base
- 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
Expand Down Expand Up @@ -111,3 +118,28 @@ jobs:
docker push discourse/discourse_test:slim-arm64
docker push discourse/discourse_test:slim-browsers-arm64
docker push discourse/discourse_test:release-arm64
dev:
runs-on: ubuntu-20.04
needs: base
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 discourse/discourse_dev:release-arm64 image
run: |
cd image && ruby auto_build.rb discourse_dev_arm64
- name: push to dockerhub
if: success() && (github.ref == 'refs/heads/main')
env:
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
run: |
docker tag discourse/discourse_dev:build_arm64 discourse/discourse_dev:release-arm64
docker login --username discoursebuild --password $DOCKERHUB_PASSWORD
docker push discourse/discourse_dev:release-arm64
12 changes: 6 additions & 6 deletions image/auto_build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
base_arm64: {
name: "base",
tag: "discourse/base:build_arm64",
extra_args: "-f release.Dockerfile --platform linux/arm64",
extra_args: "-f release.Dockerfile --platform linux/arm64 --build-arg tag=build_slim_arm64",
},
discourse_test_build: {
name: "discourse_test",
Expand All @@ -31,7 +31,7 @@
discourse_test_build_arm64: {
name: "discourse_test",
tag: "discourse/discourse_test:build_arm64",
extra_args: "--platform linux/arm64",
extra_args: "--platform linux/arm64 --build-arg from_tag=build_arm64",
},
discourse_dev: {
name: "discourse_dev",
Expand Down Expand Up @@ -63,10 +63,10 @@ def run(command)
lines
end

def build(image)
def build(image, extra_args: "")
lines =
run(
"cd #{image[:name]} && docker buildx build . --load --no-cache --tag #{image[:tag]} #{image[:extra_args] ? image[:extra_args] : ""}",
"cd #{image[:name]} && docker buildx build . --load --no-cache --tag #{image[:tag]} #{image[:extra_args] ? image[:extra_args] : ""} #{extra_args}",
)
if lines[-1] =~ /successfully built/
raise "Error building the image for #{image[:name]}: #{lines[-1]}"
Expand All @@ -80,7 +80,7 @@ def dev_deps()
run("cp ../templates/redis.template.yml discourse_dev/redis.template.yml")
end

if ARGV.length != 1
if ARGV.length < 1
puts <<~TEXT
Usage:
ruby auto_build.rb IMAGE
Expand All @@ -100,5 +100,5 @@ def dev_deps()
puts "Building #{images[image]}"
dev_deps() if image == :discourse_dev

build(images[image])
build(images[image], extra_args: ARGV.length > 1 ? ARGV[1..-1].join(" ") : "")
end
3 changes: 2 additions & 1 deletion image/discourse_test/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ARG from_tag=build
ARG from=discourse/base

FROM discourse/base:$from_tag AS base
FROM $from:$from_tag AS base
ENV RAILS_ENV test

WORKDIR /var/www/discourse
Expand Down

0 comments on commit 38cf7e3

Please sign in to comment.