DEV: Fix aarch64 build (#592)
authorDavid Taylor <david@taylorhq.com>
Wed, 15 Dec 2021 00:09:46 +0000 (00:09 +0000)
committerGitHub <noreply@github.com>
Wed, 15 Dec 2021 00:09:46 +0000 (00:09 +0000)
buildx can't build `FROM` a local image, so we need to set up a temporary local registry for the intermediate image

.github/workflows/build.yml
image/base/release.Dockerfile

index 1e5279dc0ec3658cfe46efac17a0f0edae22b741..e994a4bc044b094619592dec625674ea0728d132 100644 (file)
@@ -114,6 +114,11 @@ jobs:
   aarch64:
     runs-on: [ubuntu-20.04]
     needs: base
+    services:
+      registry:
+        image: registry
+        ports:
+          - 5000:5000
     steps:
       - uses: actions/checkout@v2
         with:
@@ -123,11 +128,28 @@ jobs:
       - name: Set up Docker Buildx
         id: buildx
         uses: docker/setup-buildx-action@v1
-      - name: build base image for aarch64
+      - name: build slim image
+        working-directory: image/base
+        run: |
+          docker buildx build . --load \
+            -f slim.Dockerfile \
+            --platform linux/arm64 \
+            --tag discourse/base:aarch64-slim
+          docker tag discourse/base:aarch64-slim localhost:5000/discourse/base:aarch64-slim
+          docker push localhost:5000/discourse/base:aarch64-slim 
+      - name: build release image
+        working-directory: image/base
         run: |
-          cd image/base
-          docker buildx build . -f slim.Dockerfile --platform linux/arm64 --load --tag discourse/base:aarch64-slim
-          docker buildx build . -f release.Dockerfile --platform linux/arm64 --load --tag discourse/base:aarch64 --build-arg tag=aarch64-slim
+          docker buildx create --name builder --use --driver-opt network=host
+          docker buildx build . --load \
+            -f release.Dockerfile \
+            --platform linux/arm64 \
+            --network=host \
+            --build-arg from=localhost:5000/discourse/base \
+            --build-arg tag=aarch64-slim \
+            --tag discourse/base:aarch64
+      - name: Print summary
+        run: docker images discourse/base
       - name: push to dockerhub
         if: success() && (github.ref == 'refs/heads/main')
         env:
index c087bde39e20323f181d1ebeab0be7eb567b4bc1..49ec6251b6d3277f45a02973ee631e46e3ab545c 100644 (file)
@@ -1,6 +1,7 @@
+ARG from=discourse/base
 ARG tag=build_slim
 
-FROM discourse/base:$tag
+FROM $from:$tag
 
 RUN cd /var/www/discourse &&\
     sudo -u discourse bundle install --deployment --jobs 4 --without test development &&\