containerfile: remove vendored jaraco from setuptools, purge pip cache

This commit is contained in:
Username
2026-01-20 08:28:26 +01:00
parent 5a05af4764
commit f5f2f8f363
2 changed files with 13 additions and 12 deletions

View File

@@ -16,10 +16,11 @@ RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN pip install --no-cache-dir --upgrade pip wheel
# Install Python dependencies (includes security pins for setuptools, jaraco.context)
# Install Python dependencies (includes security pins from requirements.txt)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt gunicorn \
&& rm -rf /opt/venv/lib/python*/site-packages/setuptools/_vendor/jaraco.context*.dist-info
&& pip cache purge 2>/dev/null || true \
&& rm -rf /opt/venv/lib/python*/site-packages/setuptools/_vendor/jaraco*
# Stage 2: Runtime image
@@ -32,7 +33,8 @@ LABEL description="Lightweight secure pastebin REST API"
# Note: System packages upgraded for Trivy scan; app runs from venv
RUN apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& pip install --no-cache-dir --upgrade pip 'setuptools>=80.0' 'jaraco.context>=6.1.0' \
&& rm -rf /usr/local/lib/python*/site-packages/setuptools/_vendor/jaraco.context*.dist-info \
&& pip cache purge 2>/dev/null || true \
&& rm -rf /root/.cache /usr/local/lib/python*/site-packages/setuptools/_vendor/jaraco* \
&& groupadd -r flaskpaste && useradd -r -g flaskpaste flaskpaste
# Copy virtual environment from builder