添加 Dockerfile

This commit is contained in:
ywp
2025-06-14 16:19:16 +08:00
parent db8b5cb367
commit cc330a8d8c

25
Dockerfile Normal file
View 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;"]