web-01-api/Dockerfile
2026-06-22 10:26:29 +08:00

47 lines
1.1 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 构建阶段
FROM crpi-jlsdxetsdmy4ckxh.cn-shenzhen.personal.cr.aliyuncs.com/zsq_proxy/node:20-alpine AS build
WORKDIR /app
# 添加构建参数
ARG BUILD_VERSION
ARG BUILD_TIME
ARG CACHE_BUST
ENV BUILD_VERSION=$BUILD_VERSION
ENV BUILD_TIME=$BUILD_TIME
# 强制打破 Docker 缓存
RUN echo "Cache bust: ${CACHE_BUST} - ${BUILD_VERSION} - ${BUILD_TIME}"
# 安装 pnpm
RUN npm install -g pnpm && \
pnpm config set registry https://registry.npmmirror.com
COPY package*.json ./
# 如果项目有 pnpm-lock.yaml取消注释下面一行
# COPY pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
COPY . .
# 强制清理 .next
RUN rm -rf .next
# 构建
RUN pnpm build
# 部署阶段
FROM crpi-jlsdxetsdmy4ckxh.cn-shenzhen.personal.cr.aliyuncs.com/zsq_proxy/node:20-alpine AS app
WORKDIR /app
ENV NODE_ENV=production
ENV NODE_OPTIONS="--max-old-space-size=4096"
COPY --from=build /app/.next ./.next
COPY --from=build /app/public ./public
COPY --from=build /app/package.json ./package.json
COPY --from=build /app/node_modules ./node_modules
EXPOSE 3003
CMD ["pnpm", "start"]