@@ -9,11 +9,20 @@ RUN apt-get update && \
99 supervisor curl \
1010 && apt-get clean && rm -rf /var/lib/apt/lists/*
1111
12+ # Install Poetry
13+ ENV POETRY_HOME="/opt/poetry"
14+ ENV POETRY_VERSION=1.8.3
15+ RUN curl -sSL https://install.python-poetry.org | python3 - --version ${POETRY_VERSION}
16+ ENV PATH="${POETRY_HOME}/bin:${PATH}"
17+
1218WORKDIR /app_builder
13- COPY requirements.txt ./
14- RUN pip install --no-cache-dir --upgrade pip && \
15- pip install --no-cache-dir -U "camoufox[geoip]" && \
16- pip install --no-cache-dir -r requirements.txt
19+
20+ # Copy Poetry project files
21+ COPY pyproject.toml poetry.lock ./
22+
23+ # Configure Poetry to not create virtualenvs and install dependencies
24+ RUN poetry config virtualenvs.create false --local && \
25+ poetry install --no-root --no-dev --no-interaction --no-ansi
1726
1827FROM python:3.10-slim-bookworm
1928
@@ -28,11 +37,17 @@ RUN groupadd -r appgroup && useradd -r -g appgroup -s /bin/bash -d /app appuser
2837
2938WORKDIR /app
3039
40+ # Copy installed packages and executables from builder stage
3141COPY --from=builder /usr/local/lib/python3.10/site-packages/ /usr/local/lib/python3.10/site-packages/
3242COPY --from=builder /usr/local/bin/ /usr/local/bin/
43+ COPY --from=builder /opt/poetry/bin/poetry /usr/local/bin/poetry
3344
45+ # Copy application code
3446COPY . .
3547
48+ # Install Playwright browsers and dependencies, and fetch camoufox
49+ # Note: poetry is now available in the final image if needed for any build scripts,
50+ # but dependencies should already be installed.
3651RUN camoufox fetch && \
3752 python -m playwright install firefox && \
3853 python -m playwright install-deps firefox
@@ -69,7 +84,7 @@ ENV PLAYWRIGHT_BROWSERS_PATH=/home/appuser/.cache/ms-playwright
6984
7085ENV PYTHONUNBUFFERED=1
7186
72- # 默认环境变量 (可被 .env 文件或运行时环境变量覆盖 )
87+ # Default environment variables (can be overridden by .env or runtime )
7388ENV PORT=8000
7489ENV DEFAULT_FASTAPI_PORT=2048
7590ENV DEFAULT_CAMOUFOX_PORT=9222
@@ -78,7 +93,7 @@ ENV SERVER_LOG_LEVEL=INFO
7893ENV DEBUG_LOGS_ENABLED=false
7994ENV AUTO_CONFIRM_LOGIN=true
8095
81- # 向后兼容的环境变量
96+ # Backward compatibility
8297ENV SERVER_PORT=2048
8398ENV INTERNAL_CAMOUFOX_PROXY=""
8499
0 commit comments