feat: self-hosted frontend JS (offline) + docker hardening
- Vendored epub.js/pdf.js+worker/JSZip/DOMPurify in static/vendor/ - reader.html/reader.js servono i JS da /static (niente CDN, offline-ready) - CSP: rimosse allowlist CDN, aggiunto worker-src 'self' blob: - Test CSP aggiornati; tutti 16 verdi; verificato smoke test offline in container
This commit is contained in:
1 parent
e62c50c616
commit
0f15b7958f
31 files changed
+1363
-215
No files matched your search
+52
@@ -0,0 +1,52 @@
|
||||
FROM python:3.12-slim-bookworm AS builder
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
COPY requirements.txt requirements.lock ./
|
||||
RUN python -m venv /opt/venv \
|
||||
&& /opt/venv/bin/pip install --no-cache-dir --upgrade pip \
|
||||
&& /opt/venv/bin/pip install --no-cache-dir -r requirements.lock
|
||||
|
||||
FROM python:3.12-slim-bookworm AS runtime
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
pandoc \
|
||||
libcairo2 \
|
||||
libpango-1.0-0 \
|
||||
libpangocairo-1.0-0 \
|
||||
libpangoft2-1.0-0 \
|
||||
libharfbuzz0b \
|
||||
libgdk-pixbuf-2.0-0 \
|
||||
libffi8 \
|
||||
shared-mime-info \
|
||||
fonts-dejavu-core \
|
||||
fonts-liberation \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN groupadd --gid 1000 bookish \
|
||||
&& useradd --uid 1000 --gid 1000 --create-home --home-dir /home/bookish bookish
|
||||
|
||||
COPY --from=builder /opt/venv /opt/venv
|
||||
|
||||
WORKDIR /app
|
||||
COPY --chown=bookish:bookish app.py config.py gunicorn.conf.py ./
|
||||
COPY --chown=bookish:bookish bookish ./bookish
|
||||
|
||||
ENV PATH="/opt/venv/bin:$PATH" \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
BOOKISH_DATA_DIR=/data \
|
||||
BOOKISH_DEBUG=false \
|
||||
PORT=5000
|
||||
|
||||
RUN mkdir -p /data/uploads /data/converted \
|
||||
&& chown -R bookish:bookish /data /app
|
||||
|
||||
USER bookish
|
||||
EXPOSE 5000
|
||||
VOLUME ["/data"]
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
||||
CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:5000/healthz', timeout=3)"
|
||||
|
||||
CMD ["gunicorn", "--config", "gunicorn.conf.py", "app:app"]
|
||||
Reference in new issue
Block a user