File tree Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change 1
- FROM python:3.10-slim
1
+ # Stage 1: Build dependencies
2
+ FROM python:3.10-slim AS builder
2
3
3
4
WORKDIR /app
4
5
5
- # 复制所需文件到容器中
6
- COPY ./requirements.txt /app
7
- COPY ./VERSION /app
6
+ # Upgrade pip and setuptools
7
+ RUN pip install --upgrade pip setuptools
8
8
9
+ # Copy and install requirements
10
+ # This layer is cached and only re-runs when requirements.txt changes
11
+ COPY ./requirements.txt /app/
9
12
RUN pip install --no-cache-dir -r requirements.txt
13
+
14
+ # Stage 2: Final application image
15
+ FROM python:3.10-slim
16
+
17
+ WORKDIR /app
18
+
19
+ # Copy installed packages from the builder stage
20
+ COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
21
+
22
+ # Copy the application code
10
23
COPY ./app /app/app
24
+ COPY ./VERSION /app
25
+
26
+ # Set environment variables
11
27
ENV API_KEYS='["your_api_key_1"]'
12
28
ENV ALLOWED_TOKENS='["your_token_1"]'
13
29
ENV TZ='Asia/Shanghai'
You can’t perform that action at this time.
0 commit comments