-
Notifications
You must be signed in to change notification settings - Fork 1
231 lines (204 loc) · 7.92 KB
/
Copy pathbuild-base-image.yaml
File metadata and controls
231 lines (204 loc) · 7.92 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
name: Build Base Docker Image
on:
workflow_dispatch:
inputs:
image_name:
description: 'Docker image name'
required: false
default: 'openlist-base-image'
schedule:
- cron: '0 20 * * *' # 每天UTC时间20点,即北京时间4点
env:
IMAGE_NAME: ${{ github.event.inputs.image_name || 'openlist-base-image' }}
DOCKERHUB_ORG_NAME: ${{ vars.DOCKERHUB_ORG_NAME || github.repository_owner }}
GHCR_ORG_NAME: ${{ vars.GHCR_ORG_NAME || github.repository_owner }}
GHCR_REGISTRY: ghcr.io
RELEASE_PLATFORMS: 'linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/ppc64le,linux/riscv64'
LOONG64_PLATFORM: 'linux/loong64'
ALPINE_VERSION: ${{ vars.ALPINE_VERSION || '3.24' }}
permissions:
packages: write
jobs:
# 构建除龙芯外的所有架构
build-base-image:
name: Build Base Docker Image (Multi-arch)
runs-on: ubuntu-latest
strategy:
matrix:
image: ["base", "ffmpeg", "aria2", "aio"]
include:
- image: "base"
build_arg: ""
- image: "ffmpeg"
build_arg: "INSTALL_FFMPEG=true"
- image: "aria2"
build_arg: "INSTALL_ARIA2=true"
- image: "aio"
build_arg: "INSTALL_FFMPEG=true\nINSTALL_ARIA2=true"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.GHCR_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub Container Registry
uses: docker/login-action@v3
with:
username: ${{ env.DOCKERHUB_ORG_NAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image (Multi-arch)
uses: docker/build-push-action@v6
id: build
with:
context: ./base
file: ./base/Dockerfile
push: true
pull: true
no-cache: true
build-args: |
${{ matrix.build_arg }}
ALPINE_VERSION=${{ env.ALPINE_VERSION }}
tags: |
${{ env.DOCKERHUB_ORG_NAME }}/${{ env.IMAGE_NAME }}
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_ORG_NAME }}/${{ env.IMAGE_NAME }}
platforms: ${{ env.RELEASE_PLATFORMS }}
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p ${{ runner.temp }}/digests-${{ matrix.image }}
digest="${{ steps.build.outputs.digest }}"
touch "${{ runner.temp }}/digests-${{ matrix.image }}/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.image }}-multiarch
path: ${{ runner.temp }}/digests-${{ matrix.image }}/*
if-no-files-found: error
retention-days: 1
# 单独构建龙芯架构
build-loong64:
name: Build Base Docker Image (LoongArch64)
runs-on: ubuntu-latest
strategy:
matrix:
image: ["base", "ffmpeg", "aria2", "aio"]
include:
- image: "base"
build_arg: ""
- image: "ffmpeg"
build_arg: "INSTALL_FFMPEG=true"
- image: "aria2"
build_arg: "INSTALL_ARIA2=true"
- image: "aio"
build_arg: "INSTALL_FFMPEG=true\nINSTALL_ARIA2=true"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.GHCR_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub Container Registry
uses: docker/login-action@v3
with:
username: ${{ env.DOCKERHUB_ORG_NAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image (LoongArch64)
uses: docker/build-push-action@v6
id: build
with:
context: ./base
file: ./base/Dockerfile.loong64
push: true
pull: true
no-cache: true
build-args: |
${{ matrix.build_arg }}
LOONG_ALPINE_VERSION=${{ env.ALPINE_VERSION }}
tags: |
${{ env.DOCKERHUB_ORG_NAME }}/${{ env.IMAGE_NAME }}
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_ORG_NAME }}/${{ env.IMAGE_NAME }}
platforms: ${{ env.LOONG64_PLATFORM }}
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p ${{ runner.temp }}/digests-${{ matrix.image }}
digest="${{ steps.build.outputs.digest }}"
touch "${{ runner.temp }}/digests-${{ matrix.image }}/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.image }}-loong64
path: ${{ runner.temp }}/digests-${{ matrix.image }}/*
if-no-files-found: error
retention-days: 1
# 合并所有架构的manifest
merge:
name: Merge ${{ matrix.image }} manifests
runs-on: ubuntu-latest
strategy:
matrix:
image: ["base", "ffmpeg", "aria2", "aio"]
needs:
- build-base-image
- build-loong64
steps:
- name: Download digests (Multi-arch)
uses: actions/download-artifact@v4
with:
name: digests-${{ matrix.image }}-multiarch
path: ${{ runner.temp }}/digests-${{ matrix.image }}
- name: Download digests (LoongArch64)
uses: actions/download-artifact@v4
with:
name: digests-${{ matrix.image }}-loong64
path: ${{ runner.temp }}/digests-${{ matrix.image }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.GHCR_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub Container Registry
uses: docker/login-action@v3
with:
username: ${{ env.DOCKERHUB_ORG_NAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Create manifest list and push
working-directory: ${{ runner.temp }}/digests-${{ matrix.image }}
run: |
echo "🔍 Available digests for ${{ matrix.image }}:"
ls -la
# Create manifest for DockerHub
echo "📦 Creating DockerHub manifest for ${{ matrix.image }}..."
docker buildx imagetools create \
-t ${{ env.DOCKERHUB_ORG_NAME }}/${{ env.IMAGE_NAME }}:${{ matrix.image }} \
$(printf '${{ env.DOCKERHUB_ORG_NAME }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
# Create manifest for GHCR
echo "📦 Creating GHCR manifest for ${{ matrix.image }}..."
docker buildx imagetools create \
-t ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_ORG_NAME }}/${{ env.IMAGE_NAME }}:${{ matrix.image }} \
$(printf '${{ env.GHCR_REGISTRY }}/${{ env.GHCR_ORG_NAME }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
- name: Inspect image
run: |
echo "🔍 Inspecting DockerHub image..."
res=$(docker buildx imagetools inspect ${{ env.DOCKERHUB_ORG_NAME }}/${{ env.IMAGE_NAME }}:${{ matrix.image }} 2>&1)
echo "$res"
echo "🔍 Inspecting GHCR image..."
res=$(docker buildx imagetools inspect ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_ORG_NAME }}/${{ env.IMAGE_NAME }}:${{ matrix.image }} 2>&1)
echo "$res"