Committed by
GitHub
Merge pull request #114 from luojiyin1987/improve-dockerfile-build
Improve Dockerfile build configuration and layer caching
Showing
1 changed file
with
14 additions
and
10 deletions
| 1 | FROM python:3.11-slim | 1 | FROM python:3.11-slim |
| 2 | 2 | ||
| 3 | -# Prevent Python from writing .pyc files and buffer stdout/stderr | 3 | +SHELL ["/bin/bash", "-o", "pipefail", "-c"] |
| 4 | + | ||
| 5 | +# Prevent Python from writing .pyc files, buffer stdout/stderr, and pin common tooling paths | ||
| 4 | ENV PYTHONDONTWRITEBYTECODE=1 \ | 6 | ENV PYTHONDONTWRITEBYTECODE=1 \ |
| 5 | PYTHONUNBUFFERED=1 \ | 7 | PYTHONUNBUFFERED=1 \ |
| 6 | - PIP_NO_CACHE_DIR=1 | 8 | + PIP_NO_CACHE_DIR=1 \ |
| 9 | + PATH="/root/.local/bin:${PATH}" \ | ||
| 10 | + PLAYWRIGHT_BROWSERS_PATH=/ms-playwright | ||
| 7 | 11 | ||
| 8 | # Install system dependencies required by scientific Python stack, Playwright, and Streamlit | 12 | # Install system dependencies required by scientific Python stack, Playwright, and Streamlit |
| 9 | RUN apt-get update && apt-get install -y --no-install-recommends \ | 13 | RUN apt-get update && apt-get install -y --no-install-recommends \ |
| @@ -34,24 +38,24 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ | @@ -34,24 +38,24 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| 34 | ffmpeg \ | 38 | ffmpeg \ |
| 35 | && apt-get clean && rm -rf /var/lib/apt/lists/* | 39 | && apt-get clean && rm -rf /var/lib/apt/lists/* |
| 36 | 40 | ||
| 37 | -# Install uv and expose it on PATH | ||
| 38 | -ENV PATH="/root/.local/bin:${PATH}" | ||
| 39 | -RUN curl -LsSf https://astral.sh/uv/install.sh | sh | 41 | +# Install the latest uv release and expose it on PATH |
| 42 | +RUN curl -LsSf --retry 3 --retry-delay 2 --proto '=https' --proto-redir '=https' --tlsv1.2 https://astral.sh/uv/install.sh | sh | ||
| 40 | 43 | ||
| 41 | WORKDIR /app | 44 | WORKDIR /app |
| 42 | 45 | ||
| 43 | # Install Python dependencies first to leverage Docker layer caching | 46 | # Install Python dependencies first to leverage Docker layer caching |
| 44 | -COPY requirements.txt ./ | ||
| 45 | -RUN uv pip install --system -r requirements.txt && \ | ||
| 46 | - python -m playwright install chromium | 47 | +COPY requirements.txt ./ |
| 48 | +RUN uv pip install --system -r requirements.txt | ||
| 49 | + | ||
| 50 | +# Install Playwright browser binaries (system deps already handled above) | ||
| 51 | +RUN python -m playwright install chromium | ||
| 47 | 52 | ||
| 48 | # Copy application source | 53 | # Copy application source |
| 49 | COPY . . | 54 | COPY . . |
| 50 | 55 | ||
| 51 | # Ensure runtime directories exist even if ignored in build context | 56 | # Ensure runtime directories exist even if ignored in build context |
| 52 | -RUN mkdir -p logs final_reports insight_engine_streamlit_reports media_engine_streamlit_reports query_engine_streamlit_reports | 57 | +RUN mkdir -p /ms-playwright logs final_reports insight_engine_streamlit_reports media_engine_streamlit_reports query_engine_streamlit_reports |
| 53 | 58 | ||
| 54 | -# Expose Flask and Streamlit ports | ||
| 55 | EXPOSE 5000 8501 8502 8503 | 59 | EXPOSE 5000 8501 8502 8503 |
| 56 | 60 | ||
| 57 | # Default command launches the Flask orchestrator which starts Streamlit agents | 61 | # Default command launches the Flask orchestrator which starts Streamlit agents |
-
Please register or login to post a comment