ZhaoShanGeng commited on
Commit ·
445a946
1
Parent(s): 91281d5
feat: 支持 amd64 和 arm64 两个独立的 Docker 镜像
Browse files- 分别构建 linux-x64 和 linux-arm64 镜像
- amd64 镜像标签: binary-build, binary
- arm64 镜像标签: binary-build-arm64, binary-arm64
- Dockerfile 使用通配符匹配不同架构的二进制文件
- .github/workflows/docker-publish.yml +16 -7
- Dockerfile.binary +3 -2
.github/workflows/docker-publish.yml
CHANGED
|
@@ -15,12 +15,21 @@ jobs:
|
|
| 15 |
permissions:
|
| 16 |
contents: read
|
| 17 |
packages: write
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
steps:
|
| 20 |
- name: Checkout
|
| 21 |
uses: actions/checkout@v4
|
| 22 |
|
| 23 |
-
# 二进制构建:先编译再构建 Docker
|
| 24 |
- name: Setup Node.js
|
| 25 |
uses: actions/setup-node@v4
|
| 26 |
with:
|
|
@@ -30,8 +39,8 @@ jobs:
|
|
| 30 |
- name: Install dependencies
|
| 31 |
run: npm ci
|
| 32 |
|
| 33 |
-
- name: Build
|
| 34 |
-
run: npm run build:
|
| 35 |
|
| 36 |
- name: List dist contents
|
| 37 |
run: |
|
|
@@ -42,7 +51,7 @@ jobs:
|
|
| 42 |
|
| 43 |
- name: Set executable permissions
|
| 44 |
run: |
|
| 45 |
-
chmod +x dist/antigravity-
|
| 46 |
chmod +x dist/bin/* || true
|
| 47 |
|
| 48 |
- name: Set up Docker Buildx
|
|
@@ -61,10 +70,10 @@ jobs:
|
|
| 61 |
with:
|
| 62 |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
| 63 |
tags: |
|
| 64 |
-
type=ref,event=branch
|
| 65 |
-
type=raw,value=binary,enable=true
|
| 66 |
|
| 67 |
-
- name: Build and push
|
| 68 |
uses: docker/build-push-action@v5
|
| 69 |
with:
|
| 70 |
context: .
|
|
|
|
| 15 |
permissions:
|
| 16 |
contents: read
|
| 17 |
packages: write
|
| 18 |
+
|
| 19 |
+
strategy:
|
| 20 |
+
matrix:
|
| 21 |
+
include:
|
| 22 |
+
- target: linux
|
| 23 |
+
arch: amd64
|
| 24 |
+
tag_suffix: ""
|
| 25 |
+
- target: linux-arm64
|
| 26 |
+
arch: arm64
|
| 27 |
+
tag_suffix: "-arm64"
|
| 28 |
|
| 29 |
steps:
|
| 30 |
- name: Checkout
|
| 31 |
uses: actions/checkout@v4
|
| 32 |
|
|
|
|
| 33 |
- name: Setup Node.js
|
| 34 |
uses: actions/setup-node@v4
|
| 35 |
with:
|
|
|
|
| 39 |
- name: Install dependencies
|
| 40 |
run: npm ci
|
| 41 |
|
| 42 |
+
- name: Build binary for ${{ matrix.arch }}
|
| 43 |
+
run: npm run build:${{ matrix.target }}
|
| 44 |
|
| 45 |
- name: List dist contents
|
| 46 |
run: |
|
|
|
|
| 51 |
|
| 52 |
- name: Set executable permissions
|
| 53 |
run: |
|
| 54 |
+
chmod +x dist/antigravity-* || true
|
| 55 |
chmod +x dist/bin/* || true
|
| 56 |
|
| 57 |
- name: Set up Docker Buildx
|
|
|
|
| 70 |
with:
|
| 71 |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
| 72 |
tags: |
|
| 73 |
+
type=ref,event=branch,suffix=${{ matrix.tag_suffix }}
|
| 74 |
+
type=raw,value=binary${{ matrix.tag_suffix }},enable=true
|
| 75 |
|
| 76 |
+
- name: Build and push (${{ matrix.arch }})
|
| 77 |
uses: docker/build-push-action@v5
|
| 78 |
with:
|
| 79 |
context: .
|
Dockerfile.binary
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
# 这个镜像更小,启动更快,内存占用更低
|
| 3 |
#
|
| 4 |
# 构建方式:
|
| 5 |
-
# 1. 先运行 npm run build:linux 生成 dist 目录
|
| 6 |
# 2. 然后运行 docker build -f Dockerfile.binary -t antigravity .
|
| 7 |
|
| 8 |
FROM debian:bookworm-slim
|
|
@@ -15,7 +15,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 15 |
&& rm -rf /var/lib/apt/lists/*
|
| 16 |
|
| 17 |
# 复制编译后的文件(由 CI 工作流预先编译)
|
| 18 |
-
|
|
|
|
| 19 |
COPY dist/public /app/public
|
| 20 |
COPY dist/bin /app/bin
|
| 21 |
COPY dist/config.json /app/config.json
|
|
|
|
| 2 |
# 这个镜像更小,启动更快,内存占用更低
|
| 3 |
#
|
| 4 |
# 构建方式:
|
| 5 |
+
# 1. 先运行 npm run build:linux 或 npm run build:linux-arm64 生成 dist 目录
|
| 6 |
# 2. 然后运行 docker build -f Dockerfile.binary -t antigravity .
|
| 7 |
|
| 8 |
FROM debian:bookworm-slim
|
|
|
|
| 15 |
&& rm -rf /var/lib/apt/lists/*
|
| 16 |
|
| 17 |
# 复制编译后的文件(由 CI 工作流预先编译)
|
| 18 |
+
# 使用通配符匹配不同架构的二进制文件
|
| 19 |
+
COPY dist/antigravity-linux-* /app/antigravity
|
| 20 |
COPY dist/public /app/public
|
| 21 |
COPY dist/bin /app/bin
|
| 22 |
COPY dist/config.json /app/config.json
|