Files
index/Dockerfile
T

22 lines
846 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.
# =============================================================================
# 仅用于「构建」:容器内完成 npm ci + npm run build,产出 /app/dist
#
# Jenkins 用 `docker build --target build` 构建本阶段,再用 docker cp 把
# /app/dist 导出到宿主机,最后由 1Panel 的 Nginx 托管。
# 宿主机的 Jenkins 无需安装 Node。
#
# 本地验证:
# docker build --target build -t index-build .
# docker create --name tmp index-build && docker cp tmp:/app/dist/. ./dist && docker rm tmp
# =============================================================================
FROM node:22-alpine AS build
WORKDIR /app
# 先拷依赖清单,单独成层以复用构建缓存
COPY package.json package-lock.json ./
RUN npm ci
# 再拷源码与构建脚本(忽略项见 .dockerignore)
COPY . .
RUN npm run build