Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: Build base images for ARM64 platform in a seperate daily job #744

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions .github/workflows/arm64-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
on:
pull_request:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enabling it on pull requests first so that we run the job in this PR and I know I got things right. Will remove before merging.

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:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is alot of duplication between this new workflow and build.yml but I want to get things running and see if we can even run everything in a reasonable amount of time first.

base:
runs-on: ubuntu-20.04
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
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
# docker push localhost:5000/discourse/base:build_slim_arm64
- name: build release image
run: |
cd image && ruby auto_build.rb base_arm64 --build-arg from=tgxworld/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 tag discourse/base:build_arm64 localhost:5000/discourse/base:build_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 --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
- 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
test:
runs-on: ubuntu-20.04
needs: base
defaults:
run:
working-directory: image/discourse_test
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_test:slim-arm64
run: |
docker buildx build . --load \
--build-arg from_tag=slim-arm64 \
--target base \
--tag discourse/discourse_test:slim-arm64
- name: build discourse/discourse_test:slim-browsers-arm64
run: |
docker buildx build . --load \
--build-arg from_tag=slim-arm64 \
--target with_browsers \
--tag discourse/discourse_test:slim-browsers-arm64
- name: build discourse/discourse_test:release-arm64
run: |
docker buildx build . --load \
--build-arg from_tag=release-arm64 \
--target release \
--tag discourse/discourse_test:release-arm64
- name: Print summary
run: |
docker images discourse/discourse_test
- 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/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
28 changes: 0 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,31 +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
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
- name: tag slim image as release
working-directory: image/base
run: |
docker tag discourse/base:build_slim_arm64 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
23 changes: 19 additions & 4 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 --build-arg tag=build_slim_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 --build-arg from_tag=build_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 All @@ -48,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 @@ -65,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 @@ -85,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
1 change: 1 addition & 0 deletions image/base/release.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ RUN cd /var/www/discourse &&\
sudo -u discourse bundle config --local without test development &&\
sudo -u discourse bundle config --local jobs 4 && \
sudo -u discourse bundle install &&\
sudo -u discourse yarn config set network-timeout 600000 &&\
sudo -u discourse yarn install --frozen-lockfile &&\
sudo -u discourse yarn cache clean &&\
find /var/www/discourse/vendor/bundle -name tmp -type d -exec rm -rf {} +
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