All checks were successful
Build and Deploy LTY / build-and-deploy (push) Successful in 7m50s
- Add dev branch trigger and environment-based config (prod/dev) - Switch to Volcano container registry with retry logic - Use mirror images for Docker base images (daocloud.io) - Add dynamic domain/DB/Redis config per environment Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
52 lines
1.2 KiB
Docker
52 lines
1.2 KiB
Docker
# 构建阶段
|
||
FROM docker.m.daocloud.io/node:22.10.0-alpine AS builder
|
||
|
||
# 设置工作目录
|
||
WORKDIR /app
|
||
|
||
# 设置yarn镜像源为淘宝镜像
|
||
RUN yarn config set registry https://registry.npmmirror.com && \
|
||
yarn config set disturl https://npmmirror.com/dist --global
|
||
|
||
# 复制package.json和yarn.lock
|
||
COPY package.json yarn.lock* ./
|
||
|
||
# 安装依赖(包括devDependencies用于构建)
|
||
RUN yarn install --frozen-lockfile
|
||
|
||
# 复制源代码
|
||
COPY . .
|
||
|
||
# 构建应用
|
||
RUN yarn build
|
||
|
||
# 运行阶段
|
||
FROM docker.m.daocloud.io/node:22.10.0-alpine AS runner
|
||
|
||
# 设置工作目录
|
||
WORKDIR /app
|
||
|
||
# 设置yarn镜像源为淘宝镜像
|
||
RUN yarn config set registry https://registry.npmmirror.com && \
|
||
yarn config set disturl https://npmmirror.com/dist --global
|
||
|
||
# 复制package.json和yarn.lock
|
||
COPY package.json yarn.lock* ./
|
||
|
||
# 仅安装生产依赖
|
||
RUN yarn install --production --frozen-lockfile
|
||
|
||
# 设置环境变量
|
||
ENV NODE_ENV=production
|
||
ENV PATH=/app/node_modules/.bin:$PATH
|
||
|
||
# 从构建阶段复制构建产物
|
||
COPY --from=builder /app/.next ./.next
|
||
COPY --from=builder /app/public ./public
|
||
COPY --from=builder /app/next.config.mjs ./
|
||
|
||
# 暴露端口
|
||
EXPOSE 3000
|
||
|
||
# 启动应用
|
||
CMD ["yarn", "start"] |