添加 Dockerfile
This commit is contained in:
25
Dockerfile
Normal file
25
Dockerfile
Normal file
@ -0,0 +1,25 @@
|
||||
# 构建阶段
|
||||
FROM node:16 AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json yarn.lock ./
|
||||
RUN yarn install --frozen-lockfile
|
||||
|
||||
COPY . .
|
||||
|
||||
# 执行构建
|
||||
RUN yarn && yarn build
|
||||
|
||||
# 生产阶段(使用 Nginx 只部署静态文件)
|
||||
FROM nginx:stable-alpine
|
||||
|
||||
# 清空默认目录
|
||||
RUN rm -rf /usr/share/nginx/html/*
|
||||
|
||||
# 复制构建产物到 Nginx 目录
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
Reference in New Issue
Block a user