Skip to content

Build Docker base images #186

Build Docker base images

Build Docker base images #186

name: Build Docker base images
on:
schedule:
- cron: '0 0 * * 1'
workflow_dispatch:
jobs:
build-images:
if: github.repository == 'SignalK/signalk-server'
name: Ubuntu base image
strategy:
matrix:
os: [24.04, alpine]
node: [24.x]
vm: [ubuntu-latest, ubuntu-24.04-arm]
include:
- vm: ubuntu-latest
arch: amd
os: 24.04
node: 24.x
node_safe: 24.x
platform: linux/amd64
- vm: ubuntu-latest
arch: amd
os: alpine
node: 24.x
node_safe: 24
platform: linux/amd64
- vm: ubuntu-24.04-arm
arch: arm
os: 24.04
node: 24.x
node_safe: 24.x
platform: linux/arm64
- vm: ubuntu-24.04-arm
arch: arm
os: alpine
node: 24.x
node_safe: 24
platform: linux/arm64
runs-on: ${{ matrix.vm }}
steps:
- uses: actions/checkout@v6
- 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 Ubuntu 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 }}-${{ matrix.node_safe }}
build-args: |
NODE=${{ matrix.node_safe }}
create-and-push-manifest:
needs: [build-images]
runs-on: ubuntu-latest
strategy:
matrix:
os: [24.04, alpine]
node: [24.x]
include:
- os: 24.04
node: 24.x
node_safe: 24.x
- os: alpine
node: 24.x
node_safe: 24
steps:
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_PAT }}
- name: Create and push multi-arch manifest to GHCR
uses: int128/docker-manifest-create-action@v2
with:
tags: |
ghcr.io/signalk/signalk-server-base:latest-${{ matrix.os }}-${{ matrix.node_safe }}
sources: |
ghcr.io/signalk/signalk-server-base:amd-${{ matrix.os }}-${{ matrix.node_safe }}
ghcr.io/signalk/signalk-server-base:arm-${{ matrix.os }}-${{ matrix.node_safe }}
copy-to-dockerhub:
needs: create-and-push-manifest
runs-on: ubuntu-latest
strategy:
matrix:
os: [24.04, alpine]
node: [24.x]
include:
- os: 24.04
node: 24.x
node_safe: 24.x
- os: alpine
node: 24.x
node_safe: 24
steps:
- name: Install skopeo
run: |
sudo apt-get update
sudo apt-get install -y skopeo
- name: Copy images from GHCR to Docker Hub
shell: bash
env:
GHCR_USERNAME: ${{ github.actor }}
GHCR_TOKEN: ${{ secrets.GHCR_PAT }}
DOCKER_HUB_USERNAME: signalkci
DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
run: |
set -euo pipefail
skopeo copy --all \
--src-creds "${GHCR_USERNAME}:${GHCR_TOKEN}" \
--dest-creds "${DOCKER_HUB_USERNAME}:${DOCKER_HUB_ACCESS_TOKEN}" \
"docker://ghcr.io/signalk/signalk-server-base:latest-${{ matrix.os }}-${{ matrix.node_safe }}" \
"docker://docker.io/signalk/signalk-server-base:latest-${{ matrix.os }}-${{ matrix.node_safe }}"
housekeeping:
needs: [copy-to-dockerhub]
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Wait for GHCR indexing
run: sleep 60
- name: Remove Docker Image from GHCR
continue-on-error: true
uses: dataaxiom/ghcr-cleanup-action@v1
with:
packages: signalk-server-base
delete-untagged: true
delete-tags: |
amd-*,arm-*
token: ${{ secrets.GHCR_PAT }} # Need to have delete permission