You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
458 B
Docker
29 lines
458 B
Docker
# 构建阶段
|
|
FROM node:18-alpine as builder
|
|
|
|
WORKDIR /app
|
|
|
|
# 复制项目文件
|
|
COPY package*.json ./
|
|
|
|
# 安装依赖
|
|
RUN npm install
|
|
|
|
# 复制源代码
|
|
COPY . .
|
|
|
|
# 构建项目
|
|
RUN npm run build
|
|
|
|
# 生产阶段
|
|
FROM nginx:1.25.3-alpine
|
|
|
|
# 从构建阶段复制构建结果到nginx目录
|
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
|
|
|
# 复制nginx配置
|
|
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
EXPOSE 80
|
|
|
|
CMD ["nginx", "-g", "daemon off;"] |