Ethanmaht commited on
Commit
a1bef6d
·
verified ·
1 Parent(s): 0efc3cf

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +47 -49
Dockerfile CHANGED
@@ -1,49 +1,47 @@
1
- # 构建阶段
2
- FROM python:3.11-slim AS builder
3
-
4
- ENV PYTHONDONTWRITEBYTECODE=1 \
5
- PYTHONUNBUFFERED=1 \
6
- PIP_NO_CACHE_DIR=1
7
-
8
- WORKDIR /build
9
-
10
- # 最小化安装依赖
11
- RUN apt-get update \
12
- && apt-get install -y --no-install-recommends \
13
- build-essential \
14
- curl \
15
- && rm -rf /var/lib/apt/lists/* \
16
- && apt-get clean
17
-
18
- COPY requirements.txt .
19
- # 升级 pip 并全局安装依赖
20
- RUN pip install --upgrade pip
21
- RUN pip install --no-cache-dir -r requirements.txt
22
-
23
- # # 调试:验证依赖是否正确安装
24
- # RUN ls -la /usr/local
25
-
26
- # 运行阶段
27
- FROM python:3.11-slim AS runner
28
-
29
- ENV PYTHONDONTWRITEBYTECODE=1 \
30
- PYTHONUNBUFFERED=1 \
31
- PORT=7860 \
32
- DEBUG=false
33
-
34
- WORKDIR /app
35
-
36
- # 复制全局依赖
37
- COPY --from=builder /usr/local /usr/local
38
-
39
- COPY more_core.py .
40
- RUN chmod +x more_core.py
41
- COPY degpt.py .
42
- RUN chmod +x degpt.py
43
-
44
- HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
45
- CMD curl -f http://localhost:${PORT}/ || exit 1
46
-
47
- EXPOSE ${PORT}
48
-
49
- CMD ["python", "more_core.py"]
 
1
+ # Build stage
2
+ FROM python:3.11-slim-bullseye AS builder
3
+
4
+ ENV PYTHONDONTWRITEBYTECODE=1 \
5
+ PYTHONUNBUFFERED=1 \
6
+ PIP_NO_CACHE_DIR=1 \
7
+ DEBIAN_FRONTEND=noninteractive
8
+
9
+ WORKDIR /build
10
+
11
+ # Install minimal dependencies and Python packages
12
+ RUN apt-get update && apt-get install -y --no-install-recommends \
13
+ curl \
14
+ ca-certificates \
15
+ && rm -rf /var/lib/apt/lists/* \
16
+ && pip install --upgrade pip
17
+
18
+ COPY requirements.txt .
19
+ RUN pip install --no-cache-dir -r requirements.txt
20
+
21
+ # Runtime stage
22
+ FROM python:3.11-slim-bullseye
23
+
24
+ ENV PYTHONDONTWRITEBYTECODE=1 \
25
+ PYTHONUNBUFFERED=1 \
26
+ PORT=7860 \
27
+ DEBUG=false
28
+
29
+ WORKDIR /app
30
+
31
+ # Copy Python packages and application files
32
+ COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
33
+ COPY more_core.py degpt.py ./
34
+
35
+ # Install runtime dependencies
36
+ RUN apt-get update && apt-get install -y --no-install-recommends \
37
+ curl \
38
+ ca-certificates \
39
+ && rm -rf /var/lib/apt/lists/*
40
+
41
+ # Healthcheck and entrypoint
42
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
43
+ CMD curl -f http://localhost:${PORT}/health || exit 1
44
+
45
+ EXPOSE ${PORT}
46
+
47
+ CMD ["python", "more_core.py"]