发布 Docker 多架构镜像
GitHub Actions 同时构建 amd64 和 arm64,并移除 Compose 的平台锁定,让 Docker 根据宿主机 CPU 自动选择镜像。
This commit is contained in:
1 parent
a5a8aa9b8b
commit
fccb5eebc8
3 files changed
+12
-11
No files matched your search
@@ -19,12 +19,15 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
name: 发布 linux/amd64 镜像
|
||||
name: 发布多架构镜像
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 配置 QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: 配置 Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
@@ -57,7 +60,7 @@ jobs:
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile.debian13
|
||||
platforms: linux/amd64
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
@@ -158,9 +158,10 @@ go run ./cmd/dbverify "postgres://user:pass@host:5432/db"
|
||||
|
||||
## Docker 部署注意
|
||||
|
||||
仓库提供 `docker-compose.debian13-postgres17.yml`,用于在 x86_64 Linux 上运行
|
||||
Debian 13 应用镜像和 PostgreSQL 17。Compose 明确锁定 `linux/amd64`,即使在 ARM
|
||||
开发机上也会构建并验证 x86_64 镜像。
|
||||
仓库提供 `docker-compose.debian13-postgres17.yml`,用于运行 Debian 13 应用镜像和
|
||||
PostgreSQL 17。GHCR 中的同一镜像标签同时包含 `linux/amd64` 和 `linux/arm64`,
|
||||
Docker 会根据宿主机 CPU 自动选择:x86_64 Linux 拉取 amd64,Apple Silicon 拉取
|
||||
arm64,无需手工设置 `platform`。
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
@@ -170,7 +171,7 @@ docker compose -f docker-compose.debian13-postgres17.yml pull app postgres
|
||||
docker compose -f docker-compose.debian13-postgres17.yml up -d --no-build postgres app
|
||||
```
|
||||
|
||||
`dev` 分支会由 GitHub Actions 自动发布
|
||||
`dev` 分支会由 GitHub Actions 自动发布多架构的
|
||||
`ghcr.io/christ9038/xinayu-go:dev`;`main` 分支同时发布 `main` 和 `latest` 标签,
|
||||
版本标签(例如 `v1.2.3`)会发布对应语义化版本标签。仓库和镜像为私有时,服务器
|
||||
登录 GHCR 所用的 Personal Access Token 需要 `read:packages` 权限。本地修改镜像后
|
||||
|
||||
@@ -17,7 +17,6 @@ x-app-volumes: &app-volumes
|
||||
|
||||
services:
|
||||
postgres:
|
||||
platform: linux/amd64
|
||||
image: ${POSTGRES_IMAGE:-postgres:17-trixie}
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
@@ -37,8 +36,7 @@ services:
|
||||
start_period: 10s
|
||||
|
||||
app:
|
||||
platform: linux/amd64
|
||||
image: ${XIANYU_IMAGE:-xianyu-go:debian13-amd64}
|
||||
image: ${XIANYU_IMAGE:-xianyu-go:debian13}
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.debian13
|
||||
@@ -59,8 +57,7 @@ services:
|
||||
start_period: 30s
|
||||
|
||||
init-admin:
|
||||
platform: linux/amd64
|
||||
image: ${XIANYU_IMAGE:-xianyu-go:debian13-amd64}
|
||||
image: ${XIANYU_IMAGE:-xianyu-go:debian13}
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.debian13
|
||||
|
||||
Reference in new issue
Block a user