docker: add Docker image for ARM.

* Have CI build Docker images for both x86 and ARM.
* Add a `bin/rails danbooru:docker:build-arm` command for building a Docker image locally for ARM.

Usage:

* Test the image:

  docker run --rm -it --platform linux/arm64 ghcr.io/danbooru/danbooru bash

* Build the image:

  bin/rails danbooru:docker:build-arm

* Build the image by hand:

  git archive HEAD | docker buildx build - --platform linux/amd64 --build-arg SOURCE_COMMIT=$(git rev-parse HEAD) -t danbooru -f Dockerfile --load
This commit is contained in:
evazion
2022-04-24 18:35:03 -05:00
parent e698bf91ee
commit 2b387bdc41
3 changed files with 25 additions and 5 deletions

View File

@@ -27,6 +27,13 @@ jobs:
runs-on: ubuntu-latest
steps:
# https://github.com/docker/setup-qemu-action
# https://github.com/docker/setup-buildx-action#with-qemu
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: arm64
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
@@ -73,6 +80,8 @@ jobs:
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
platforms: linux/amd64,linux/arm64
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#registry-cache
# https://dev.to/pst418/speed-up-multi-stage-docker-builds-in-ci-cd-with-buildkit-s-registry-cache-11gi
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache