Files
frontend_v2/Dockerfile.prebuilt
toom1996 e7377a8771 build: 新增 Dockerfile.prebuilt,.dockerignore 保留 dist
- 配合后端 scripts/push-build.sh:本机 astro build 后服务器只打镜像层,不跑 npm ci + build
- .dockerignore 之前忽略 dist,会导致预构建 COPY dist 失败
- 新增 .gitattributes 固定 Dockerfile / yml / conf 为 LF
2026-10-21 00:03:06 +08:00

24 lines
681 B
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.

# 预构建镜像:dist/ 在本机 build 好(构建期 SSG 数据经 SSH 隧道取自线上),
# 服务器只装运行时依赖并打层,不跑 astro build。
# 由 backend/scripts/push-build.sh 与 backend/deploy.sh --prebuilt 使用。
FROM node:22-alpine
WORKDIR /app
ENV NODE_ENV=production \
HOST=0.0.0.0 \
PORT=3000
# 运行时依赖层:只在 package-lock 变化时重装,日常发布命中缓存
COPY package*.json ./
RUN npm ci --omit=dev && npm cache clean --force
COPY dist ./dist
EXPOSE 3000
HEALTHCHECK --interval=15s --timeout=3s --start-period=15s --retries=3 \
CMD nc -z 127.0.0.1 3000 || exit 1
CMD ["node", "./dist/server/entry.mjs"]