Build Docker base images #147
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
| name: Build Docker base images | |
| on: | |
| schedule: | |
| - cron: '0 0 * * 1' | |
| workflow_dispatch: | |
| jobs: | |
| build-images: | |
| strategy: | |
| matrix: | |
| os: [22.04, 24.04] | |
| vm: [ubuntu-latest, ubuntu-24.04-arm] | |
| include: | |
| - vm: ubuntu-latest | |
| arch: amd | |
| platform: linux/amd64 | |
| - vm: ubuntu-24.04-arm | |
| arch: arm | |
| platform: linux/arm64,linux/arm/v7 | |
| runs-on: ${{ matrix.vm }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: docker/setup-buildx-action@v3 | |
| - name: Login to ghcr.io | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GHCR_PAT }} | |
| - name: Build baseimages | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./docker/Dockerfile_base_${{ matrix.os }} | |
| platforms: ${{ matrix.platform }} | |
| push: true | |
| tags: | | |
| ghcr.io/signalk/signalk-server-base:${{ matrix.arch }}-${{ matrix.os }} | |
| - name: Modify Dockerfile_rel for testing | |
| run: | | |
| sed -i \ | |
| "s|cr.signalk.io/signalk/signalk-server-base:latest|ghcr.io/signalk/signalk-server-base:${{ matrix.arch }}-${{ matrix.os }}|g" \ | |
| ./docker/Dockerfile_rel | |
| - name: Build Signal K test docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./docker/Dockerfile_rel | |
| platforms: ${{ matrix.platform }} | |
| build-args: | | |
| TAG=latest | |
| create-and-push-manifest: | |
| needs: [build-images] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| os: [22.04, 24.04] | |
| steps: | |
| - name: Login to ghcr.io | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GHCR_PAT }} | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: signalkci | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Create and push multi-arch manifest to GHCR and Docker Hub | |
| uses: int128/docker-manifest-create-action@v2 | |
| with: | |
| tags: | | |
| ghcr.io/signalk/signalk-server-base:latest-${{ matrix.os }} | |
| signalk/signalk-server-base:latest-${{ matrix.os }} | |
| sources: | | |
| ghcr.io/signalk/signalk-server-base:amd-${{ matrix.os }} | |
| ghcr.io/signalk/signalk-server-base:arm-${{ matrix.os }} | |
| housekeeping: | |
| needs: create-and-push-manifest | |
| runs-on: ubuntu-latest | |
| permissions: | |
| packages: write | |
| steps: | |
| - name: Remove Docker Image from GHCR | |
| uses: dataaxiom/ghcr-cleanup-action@v1 | |
| with: | |
| packages: signalk-server-base | |
| delete-untagged: true | |
| delete-tags: amd-22.04,arm-22.04,amd-24.04,arm-24.04 | |
| token: ${{ secrets.GHCR_PAT }} # Need to have delete permission |