添加了docker部署相关内容

This commit is contained in:
carry
2025-02-18 16:35:47 +08:00
parent b705bbfa7d
commit b5651448b4
5 changed files with 132 additions and 2 deletions

29
frontend/Dockerfile Normal file
View File

@@ -0,0 +1,29 @@
# 使用Node.js作为基础镜像
FROM node:18-alpine as build-stage
# 设置工作目录
WORKDIR /app
# 复制package.json和package-lock.json
COPY package*.json ./
# 安装依赖
RUN npm install
# 复制项目文件
COPY . .
# 构建项目
RUN npm run build
# 使用Nginx作为生产环境
FROM nginx:stable-alpine as production-stage
# 复制构建好的文件到Nginx目录
COPY --from=build-stage /app/dist /usr/share/nginx/html
# 暴露80端口
EXPOSE 80
# 启动Nginx
CMD ["nginx", "-g", "daemon off;"]