ForcePilot/docker/web.Dockerfile
2025-02-25 14:45:28 +08:00

37 lines
905 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.

# 开发阶段
FROM node:latest AS development
WORKDIR /app
# 复制 package.json 和 package-lock.json如果存在
COPY ./web/package*.json ./
# 安装依赖
RUN npm install --verbose --force
# RUN npm install --registry http://mirrors.cloud.tencent.com/npm/ --verbose --force
# 复制源代码
COPY ./web .
# 暴露端口
EXPOSE 5173
# 启动开发服务器的命令在 docker-compose 文件中定义
# 生产阶段
FROM node:latest AS build-stage
WORKDIR /app
COPY ./web/package*.json ./
RUN npm install --force
# RUN npm install --registry https://registry.npmmirror.com --force
COPY ./web .
RUN npm run build
# 生产环境运行阶段
FROM nginx:alpine AS production
COPY --from=build-stage /app/dist /usr/share/nginx/html
COPY ./docker/nginx/nginx.conf /etc/nginx/nginx.conf
COPY ./docker/nginx/default.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]