Skip to content

Commit 9a48d00

Browse files
committed
build arm64 only
1 parent 86ddad5 commit 9a48d00

File tree

2 files changed

+25
-34
lines changed

2 files changed

+25
-34
lines changed

.github/workflows/build-and-push.yml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ env:
3232

3333
jobs:
3434
build:
35-
runs-on: ubuntu-latest
35+
runs-on: ubuntu-24.04-arm
3636
environment: production
3737
env:
3838
BUILD_OUTPUT: standalone
@@ -76,6 +76,12 @@ jobs:
7676
- name: Build Next (standalone)
7777
run: pnpm build
7878

79+
- name: Verify Build Artifacts
80+
run: |
81+
ls -la .next/standalone
82+
ls -la .next/static
83+
ls -la public
84+
7985
- name: Configure AWS credentials (OIDC)
8086
uses: aws-actions/configure-aws-credentials@v4
8187
with:
@@ -87,21 +93,17 @@ jobs:
8793
with:
8894
registry-type: public
8995

90-
# 设置 Docker Buildx
91-
- name: Set up Docker Buildx
92-
uses: docker/setup-buildx-action@v3
93-
94-
# 设置 QEMU 模拟多平台
95-
- name: Set up QEMU
96-
uses: docker/setup-qemu-action@v2
97-
98-
- name: Build & Push
96+
- name: Build and Push Docker image (ARM64 only)
9997
run: |
98+
# 1. 提取 Short SHA
10099
SHORT_SHA=${GITHUB_SHA:0:7}
101-
docker buildx build \
102-
--platform linux/amd64,linux/arm64 \
103-
-f docker/Dockerfile.CI \
104-
-t public.ecr.aws/umcai/xc2f/payload:latest \
105-
-t public.ecr.aws/umcai/xc2f/payload:$SHORT_SHA \
106-
--push \
107-
.
100+
REGISTRY=public.ecr.aws/umcai/xc2f/payload
101+
102+
# 2. 构建镜像
103+
docker build -f docker/Dockerfile.CI \
104+
-t $REGISTRY:latest \
105+
-t $REGISTRY:${SHORT_SHA} .
106+
107+
# 3. 推送镜像
108+
docker push $REGISTRY:latest
109+
docker push $REGISTRY:${SHORT_SHA}

docker/Dockerfile.CI

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,16 @@
1-
# --------------------------
2-
# Next.js 15 Standalone + Payload CMS Dockerfile
3-
# 构建阶段已经在 CI 完成
4-
# --------------------------
5-
FROM --platform=$TARGETPLATFORM node:24-alpine
1+
FROM node:24-alpine
62

7-
# 工作目录
83
WORKDIR /app
94
ENV NODE_ENV=production
105

11-
# 安装 sharp 运行依赖
12-
RUN apk add --no-cache vips fftw python3 build-base
13-
14-
# 拷贝 CI 构建产物
6+
# Next.js standalone 模式产物在 .next/standalone 下
7+
# 我们将其内容拷贝到镜像的工作目录
158
COPY .next/standalone ./
9+
10+
# 静态资源和公共文件在 .next/standalone 之外,需要手动拷入
11+
# 注意:目标路径必须是 ./.next/static 和 ./public
1612
COPY .next/static ./.next/static
1713
COPY public ./public
18-
COPY package*.json ./
1914

20-
# 安装依赖(optionalDependencies 如 sharp,针对当前平台)
21-
RUN npm ci --include=optional --omit=dev
22-
23-
# 暴露端口
2415
EXPOSE 3000
25-
26-
# 启动 Next.js / Payload
2716
CMD ["node", "server.js"]

0 commit comments

Comments
 (0)