unis_crm/frontend/Dockerfile

28 lines
673 B
Docker
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# ============ 构建阶段 ============
FROM node:20-alpine AS builder
WORKDIR /app
# 先复制 package.json利用 Docker 缓存加速依赖安装
COPY package.json package-lock.json* ./
RUN npm ci --registry=https://registry.npmmirror.com
# 复制源码并构建
COPY . .
RUN npm run build
# ============ 运行阶段 ============
FROM nginx:1.27-alpine
COPY nginx/default.conf.template /etc/nginx/default.conf.template
COPY nginx/start.sh /etc/nginx/start.sh
# 从构建阶段复制 dist
COPY --from=builder /app/dist /usr/share/nginx/html
EXPOSE 80
RUN rm -f /etc/nginx/conf.d/default.conf && chmod +x /etc/nginx/start.sh
ENTRYPOINT ["/etc/nginx/start.sh"]