Support for multi-arch (x86 + ARM64) images #34
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ci | |
on: [push, pull_request] | |
jobs: | |
build-bin: | |
name: bin | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
- name: Cache docker registry | |
uses: actions/cache@v3 | |
with: | |
key: ${{ runner.os }}-${{github.ref_name}}-b | |
path: ${{ runner.temp }}/registry | |
- name: Start local Docker registry | |
run: | | |
# Docker save / load does not support multi-arch images. | |
# This sets up a local registry that I can push the images to. | |
docker run -d -p 5000:5000 -e 'REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY=/var/lib/registry' -v '${{ runner.temp }}/registry:/var/lib/registry' registry:2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
driver-opts: network=host | |
- name: Build image | |
run: | | |
docker buildx build -f bin.dockerfile --platform=linux/amd64,linux/arm64 -t localhost:5000/bin --push . | |
build: | |
needs: build-bin | |
name: ${{ matrix.kind }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
kind: ["alpine", "centos", "debian", "distroless", "ubuntu"] | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
- name: Cache docker registry | |
uses: actions/cache@v3 | |
with: | |
key: ${{ runner.os }}-${{github.ref_name}}-b | |
fail-on-cache-miss: true | |
path: ${{ runner.temp }}/registry | |
- name: Start local Docker registry | |
run: | | |
# Docker save / load does not support multi-arch images. | |
# This sets up a local registry that I can push the images to. | |
docker run -d -p 5000:5000 -e 'REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY=/var/lib/registry' -v '${{ runner.temp }}/registry:/var/lib/registry' registry:2 | |
sleep 2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
driver-opts: network=host | |
- name: Build image | |
run: | | |
docker buildx build -f ${{ matrix.kind }}.dockerfile --platform=linux/amd64,linux/arm64 --build-arg BIN_IMAGE=localhost:5000/bin -t localhost:5000/${{ matrix.kind }} --push . | |
- name: Test default CMD | |
run: | | |
docker run --platform linux/amd64 -t localhost:5000/${{ matrix.kind }} | |
- name: Test if entry script forwards to deno binary | |
run: | | |
docker run --platform linux/amd64 -t localhost:5000/${{ matrix.kind }} eval "console.log('Welcome to Deno!')" | |
# if typescript is present in the output, then probably deno --version worked | |
docker run --platform linux/amd64 -t localhost:5000/${{ matrix.kind }} --version | grep typescript | |
- name: Test if entry script forwards to other binaries | |
if: ${{ matrix.kind != 'distroless' }} | |
run: | | |
docker run --platform linux/amd64 -t localhost:5000/${{ matrix.kind }} deno eval "console.log('Welcome to Deno!')" | |
docker run --platform linux/amd64 -t localhost:5000/${{ matrix.kind }} echo 'test entry script' | |
- name: Login to Docker Hub | |
if: github.repository == 'denoland/deno_docker' && github.ref_type == 'tag' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Push named images | |
if: github.repository == 'denoland/deno_docker' && github.ref_type == 'tag' | |
run: | | |
docker buildx imagetools create registry:8000/${{ matrix.kind }} -t denoland/deno:${{ matrix.kind }}-${{ github.ref_name }} -t denoland/deno:${{ matrix.kind }} | |
- name: Push bin image | |
if: github.repository == 'denoland/deno_docker' && github.ref_type == 'tag' && matrix.kind == 'debian' | |
run: | | |
docker buildx imagetools create registry:8000/bin -t denoland/deno:bin-${{ github.ref_name }} -t denoland/deno:bin | |
- name: Push default image | |
if: github.repository == 'denoland/deno_docker' && github.ref_type == 'tag' && matrix.kind == 'debian' | |
run: | | |
docker buildx imagetools create registry:8000/${{ matrix.kind }} -t denoland/deno:${{ matrix.kind }}-${{ github.ref_name }} -t denoland/deno:latest |