Update docker

This commit is contained in:
2025-11-04 21:36:30 +11:00
parent 7002cc3938
commit 87fa38f040
2 changed files with 15 additions and 5 deletions
+15 -5
View File
@@ -22,7 +22,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
npm \
gettext \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
&& apt-get clean \
&& npm cache clean --force
# Copy uv binary
COPY --from=uv /usr/local/bin/uv /usr/local/bin/uv
@@ -47,9 +48,10 @@ COPY static/ ./static/
RUN uv run manage.py tailwind install \
&& uv run manage.py tailwind build \
&& uv run manage.py collectstatic --noinput \
&& uv run manage.py compilemessages --locale=zh_Hans
&& uv run manage.py compilemessages --locale=zh_Hans \
&& rm -rf /app/new_theme/static_src/node_modules
# Install Playwright and browsers
# Install Playwright and browsers (chromium-headless-shell only, no full chromium)
ENV PLAYWRIGHT_BROWSERS_PATH=/app/.playwright
RUN uv run playwright install chromium --with-deps
@@ -60,7 +62,12 @@ RUN rm -rf /tmp/.cache/uv ~/.npm ~/.cache \
&& find /app -type f -name "*.md" -delete \
&& find /app -type f -name "*.txt" ! -name "requirements.txt" -delete \
&& rm -rf /app/.venv/lib/python3.12/site-packages/pip \
&& rm -rf /app/.venv/lib/python3.12/site-packages/setuptools
&& rm -rf /app/.venv/lib/python3.12/site-packages/setuptools \
&& rm -rf /app/.playwright/chromium-* \
&& rm -rf /app/.playwright/ffmpeg-* \
&& find /app/.venv -name "*.so" -exec strip {} + 2>/dev/null || true \
&& find /app/.venv -type d -name "test*" -exec rm -rf {} + 2>/dev/null || true \
&& find /app/.venv -type d -name "*test" -exec rm -rf {} + 2>/dev/null || true
# Production stage - use Python 3.12 slim
FROM python:3.12-slim AS production
@@ -104,7 +111,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libasound2 \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean \
&& rm -rf /tmp/* /var/tmp/*
&& rm -rf /tmp/* /var/tmp/* \
&& rm -rf /usr/share/doc/* \
&& rm -rf /usr/share/man/*
# Create non-root user and directories
RUN useradd -m -u 1000 appuser \
@@ -113,6 +122,7 @@ RUN useradd -m -u 1000 appuser \
&& chown -R appuser:appuser /app
# Copy only the virtual environment and built assets from builder
COPY --from=builder /usr/local/bin/uv /usr/local/bin/uv
COPY --from=builder --chown=appuser:appuser /app/.venv /app/.venv
COPY --from=builder --chown=appuser:appuser /app/.playwright /app/.playwright
COPY --from=builder --chown=appuser:appuser /app/staticfiles /app/staticfiles