Rewrite backend in Rust, add Impressum, privacy policy and account tools

New axum server in backend/ with the same HTTP API and database as the
Python one. The pl8list session is only held in memory during the feed
crawl and logged out afterwards. Local sessions use a __Host- cookie,
30-day idle expiry and weekly token rotation; the old cookie is migrated.

The audio and image proxy only accepts known parameters, fixes the content
type, follows redirects only to pl8list's file host and caches segments and
images on disk. Strict security headers, origin checks on POST, body and
concurrency limits.

/impressum and /datenschutz are rendered from env variables. The account
menu offers data export, sign out on all devices and account deletion.
hls.js is self-hosted and artist images are proxied, so the browser only
talks to this server. The Docker image builds a static binary on scratch.
This commit is contained in:
nvrl committed 2026-11-01 12:02:37 +01:00
1 parent 61af1a6dd2
commit 54a436ae48
35 files changed
+6389 -42

No files matched your search

+22 -17
View File
@@ -1,22 +1,27 @@
# syntax=docker/dockerfile:1
FROM python:3.14-alpine
FROM rust:1-alpine AS build
RUN apk add --no-cache musl-dev cmake make perl clang ca-certificates
WORKDIR /src/backend
COPY backend/Cargo.toml backend/Cargo.lock ./
# Build the dependencies once, so code changes don't rebuild them.
RUN mkdir src && echo 'fn main() {}' > src/main.rs \
&& cargo build --release --locked \
&& rm -rf src
COPY static /src/static
COPY backend ./
RUN touch src/main.rs && cargo build --release --locked \
&& mkdir -p /out/data && cp target/release/pl8inf /out/pl8inf
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
HOST=0.0.0.0 \
FROM scratch
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=build /out/pl8inf /pl8inf
COPY --from=build --chown=10001:10001 /out/data /data
ENV HOST=0.0.0.0 \
PORT=8790 \
PL8_DB=/data/pl8list.db
WORKDIR /app
COPY *.py ./
COPY static ./static
RUN python -m compileall -q . \
&& adduser -D -H -u 10001 app \
&& mkdir /data && chown app:app /data
USER app
PL8_DB=/data/pl8list.db \
SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
USER 10001:10001
VOLUME /data
EXPOSE 8790
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s \
CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8790/healthz', timeout=2)"
CMD ["python", "server.py"]
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s CMD ["/pl8inf", "--healthcheck"]
ENTRYPOINT ["/pl8inf"]