forked from SignalK/signalk-server
-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (139 loc) · 4.27 KB
/
build-base-image.yml
File metadata and controls
150 lines (139 loc) · 4.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
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