feat(docker): 重构Docker配置以支持生产环境部署
- 添加Dockerfile.dev用于开发环境 - 重构主Dockerfile使用多阶段构建 - 添加nginx配置和entrypoint脚本 - 更新docker-compose.yml配置 - 修改API基础路径为相对路径 - 更新vite配置支持环境变量
This commit is contained in:
18
Dockerfile
18
Dockerfile
@@ -1,4 +1,4 @@
|
||||
FROM node:20-alpine
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
@@ -8,6 +8,18 @@ RUN npm install
|
||||
|
||||
COPY . .
|
||||
|
||||
EXPOSE 5173
|
||||
RUN npm run build
|
||||
|
||||
CMD ["npm", "run", "dev", "--", "--host"]
|
||||
FROM nginx:alpine
|
||||
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
|
||||
COPY nginx.conf.template /etc/nginx/templates/nginx.conf.template
|
||||
|
||||
COPY entrypoint.sh /docker-entrypoint.sh
|
||||
|
||||
RUN chmod +x /docker-entrypoint.sh
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["/docker-entrypoint.sh"]
|
||||
|
||||
Reference in New Issue
Block a user