dockerfile
This commit is contained in:
27
Dockerfile
27
Dockerfile
@@ -1,16 +1,31 @@
|
||||
FROM node:18-alpine
|
||||
|
||||
# 配置Alpine国内镜像源(加速apk)
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||
# ==================== 第一阶段:构建前端 ====================
|
||||
FROM node:18-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 配置Alpine国内镜像源
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||
|
||||
COPY package*.json ./
|
||||
|
||||
RUN npm install --registry=https://registry.npmmirror.com
|
||||
|
||||
COPY . .
|
||||
|
||||
EXPOSE 8080
|
||||
RUN npm run build
|
||||
|
||||
CMD ["npm", "run", "dev"]
|
||||
# ==================== 第二阶段:部署到Nginx ====================
|
||||
FROM nginx:alpine
|
||||
|
||||
# 复制构建产物
|
||||
COPY --from=builder /app/dist/ /usr/share/nginx/html/
|
||||
|
||||
# 复制nginx配置文件
|
||||
COPY ngnix.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# 复制SSL证书
|
||||
COPY ssl/* /etc/nginx/ssl/
|
||||
|
||||
EXPOSE 80 443
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
Reference in New Issue
Block a user