diff --git a/Dockerfile b/Dockerfile index 1c36481..fff1123 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,29 @@ +# Stage 1: Build dependencies +FROM python:3.10-slim AS builder + +WORKDIR /app + +# Upgrade pip and setuptools +RUN pip install --upgrade pip setuptools + +# Copy and install requirements +# This layer is cached and only re-runs when requirements.txt changes +COPY ./requirements.txt /app/ +RUN pip install --no-cache-dir -r requirements.txt + +# Stage 2: Final application image FROM python:3.10-slim WORKDIR /app -# 复制所需文件到容器中 -COPY ./requirements.txt /app +# Copy installed packages from the builder stage +COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages + +# Copy the application code +COPY ./app /app/app COPY ./VERSION /app -RUN pip install --no-cache-dir -r requirements.txt -COPY ./app /app/app +# Set environment variables ENV API_KEYS='["your_api_key_1"]' ENV ALLOWED_TOKENS='["your_token_1"]' ENV TZ='Asia/Shanghai'