Build images #1
This file contains hidden or 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
| # Builds docker images used by CI. | |
| name: Build images | |
| # Since there are manual steps involved in switching to new images, we don't want to automatically | |
| # build new ones. So for now, we only build when someone triggers the workflow. | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| packages: write | |
| jobs: | |
| build-base: | |
| name: ${{ matrix.container }} | |
| strategy: | |
| matrix: | |
| include: | |
| - file: docker/ci/ubuntu-base.Dockerfile | |
| container: ci-ubuntu-base-amd64 | |
| runs-on: ubuntu-24.04 | |
| platform: linux/amd64 | |
| - file: docker/ci/ubuntu-base.Dockerfile | |
| container: ci-ubuntu-base-arm64 | |
| runs-on: ubuntu-24.04-arm | |
| platform: linux/arm64 | |
| - file: docker/ci/alpine.Dockerfile | |
| container: ci-alpine-amd64 | |
| runs-on: ubuntu-24.04 | |
| platform: linux/amd64 | |
| - file: docker/ci/opensuse.Dockerfile | |
| container: ci-opensuse-amd64 | |
| runs-on: ubuntu-24.04 | |
| platform: linux/amd64 | |
| - file: docker/ci/opensuse.Dockerfile | |
| container: ci-opensuse-arm64 | |
| runs-on: ubuntu-24.04-arm | |
| platform: linux/arm64 | |
| runs-on: ${{ matrix.runs-on }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.sha }} | |
| persist-credentials: false | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Log in to Container Registry | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push base image | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| file: ${{ matrix.file }} | |
| push: true | |
| platforms: ${{ matrix.platform }} | |
| tags: | | |
| ghcr.io/${{ github.repository }}/${{ matrix.container }}:latest | |
| ghcr.io/${{ github.repository }}/${{ matrix.container }}:sha-${{ github.sha }} | |
| cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/${{ matrix.container }}:buildcache | |
| cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/${{ matrix.container }}:buildcache,mode=max | |
| # Build images that depend on other images. | |
| build-dependent: | |
| name: ${{ matrix.container }} | |
| needs: build-base | |
| strategy: | |
| matrix: | |
| include: | |
| - file: docker/ci/ubuntu.Dockerfile | |
| container: ci-ubuntu-amd64 | |
| platform: linux/amd64 | |
| runs-on: ubuntu-24.04 | |
| base_image: ghcr.io/${{ github.repository }}/ci-ubuntu-base-amd64:sha-${{ github.sha }} | |
| - file: docker/ci/ubuntu.Dockerfile | |
| container: ci-ubuntu-arm64 | |
| runs-on: ubuntu-24.04-arm | |
| platform: linux/arm64 | |
| base_image: ghcr.io/${{ github.repository }}/ci-ubuntu-base-arm64:sha-${{ github.sha }} | |
| - file: docker/ci/ubuntu-cross.Dockerfile | |
| container: ci-ubuntu-cross-amd64 | |
| platform: linux/amd64 | |
| runs-on: ubuntu-24.04-arm | |
| base_image: ghcr.io/${{ github.repository }}/ci-ubuntu-base-amd64:sha-${{ github.sha }} | |
| runs-on: ${{ matrix.runs-on }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.sha }} | |
| persist-credentials: false | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Log in to Container Registry | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push dependent image | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| file: ${{ matrix.file }} | |
| push: true | |
| platforms: ${{ matrix.platform }} | |
| build-args: | | |
| BASE_IMAGE=${{ matrix.base_image }} | |
| tags: | | |
| ghcr.io/${{ github.repository }}/${{ matrix.container }}:latest | |
| ghcr.io/${{ github.repository }}/${{ matrix.container }}:sha-${{ github.sha }} | |
| cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/${{ matrix.container }}:buildcache | |
| cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/${{ matrix.container }}:buildcache,mode=max |