zhangjf 480c052ff1 feat: Docker容器化部署配置
- 添加所有后端服务的application-docker.yml配置文件
- 添加前端fund-admin和fund-mobile的Dockerfile和nginx配置
- 更新docker-compose.yml添加前端服务
- 添加.dockerignore优化构建
- 添加deploy.sh一键部署脚本
2026-02-20 10:13:52 +08:00

62 lines
1.5 KiB
Docker
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 资金服务平台移动端 - Dockerfile
# 多阶段构建Node构建 + Nginx运行
# ==================== 构建阶段 ====================
FROM node:20-alpine AS builder
WORKDIR /app
# 设置npm镜像加速下载
RUN npm config set registry https://registry.npmmirror.com
# 复制package文件利用缓存
COPY package*.json ./
# 安装依赖
RUN npm ci --legacy-peer-deps
# 复制源代码
COPY . .
# 构建参数API网关地址
ARG VITE_API_BASE_URL=http://localhost:8000
ENV VITE_API_BASE_URL=${VITE_API_BASE_URL}
# 构建生产版本
RUN npm run build
# ==================== 运行阶段 ====================
FROM nginx:alpine
# 安装必要工具
RUN apk add --no-cache curl tzdata && \
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone && \
apk del tzdata
# 删除默认配置
RUN rm -rf /etc/nginx/conf.d/default.conf
# 复制nginx配置
COPY nginx.conf /etc/nginx/conf.d/default.conf
# 复制构建产物
COPY --from=builder /app/dist /usr/share/nginx/html
# 创建非root用户
RUN chown -R nginx:nginx /usr/share/nginx/html && \
chown -R nginx:nginx /var/cache/nginx && \
chown -R nginx:nginx /var/log/nginx && \
touch /var/run/nginx.pid && \
chown -R nginx:nginx /var/run/nginx.pid
# 暴露端口
EXPOSE 80
# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD curl -f http://localhost/ || exit 1
# 启动nginx
CMD ["nginx", "-g", "daemon off;"]