dockerfile
This commit is contained in:
parent
fcb11ff406
commit
143ca04f75
19
Dockerfile
19
Dockerfile
@ -17,16 +17,19 @@ COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# 生产阶段
|
||||
FROM nginx:alpine
|
||||
FROM node:16-alpine
|
||||
|
||||
# 复制构建产物到 Nginx 目录
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 复制 Nginx 配置文件(如果需要自定义配置)
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
# 安装 serve 包来提供静态文件服务
|
||||
RUN npm install -g serve
|
||||
|
||||
# 从构建阶段复制构建产物
|
||||
COPY --from=builder /app/dist ./dist
|
||||
|
||||
# 暴露端口
|
||||
EXPOSE 80
|
||||
EXPOSE 3000
|
||||
|
||||
# 启动 Nginx
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
# 启动服务
|
||||
CMD ["serve", "-s", "dist", "-l", "3000"]
|
||||
Loading…
Reference in New Issue
Block a user