forked from RUC-GSAI/YuLan-OneSim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
67 lines (51 loc) · 1.42 KB
/
Dockerfile
File metadata and controls
67 lines (51 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# YuLan-OneSim 统一容器镜像
# 包含前端、后端、CLI 所有功能,开箱即用
FROM node:18-slim AS frontend-builder
# 构建前端
WORKDIR /frontend
COPY src/frontend/package*.json ./
RUN npm install
COPY src/frontend/ ./
RUN npm run build
# 主镜像
FROM python:3.10-slim
# 设置环境变量
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app/src \
DEBIAN_FRONTEND=noninteractive
# 安装系统依赖
RUN apt-get update && apt-get install -y \
nginx \
supervisor \
curl \
procps \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# 设置工作目录
WORKDIR /app
# 复制依赖文件并安装Python依赖
COPY setup.py README.md ./
COPY src/ ./src/
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -e .
# 复制前端构建文件到nginx目录
COPY --from=frontend-builder /frontend/dist /var/www/html
# 复制配置文件
COPY config/ ./config/
# 创建必要目录
RUN mkdir -p /app/logs /var/log/supervisor
# 复制nginx配置
COPY docker/nginx.conf /etc/nginx/nginx.conf
# 复制supervisor配置
COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# 创建启动脚本
COPY docker/start.sh /start.sh
RUN chmod +x /start.sh
# 暴露端口
EXPOSE 80
# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD curl -f http://localhost/health || exit 1
# 启动
CMD ["/start.sh"]