blob: 76d036cd43ee4289b67220c2fd7fe99c7c46b616 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# =============================================================================
# yt-local — non-root, Tor-ready
# =============================================================================
FROM python:3.11-alpine
LABEL maintainer="heckyel@riseup.net"
LABEL org.opencontainers.image.source="https://git.sr.ht/~heckyel/yt-local"
LABEL org.opencontainers.image.licenses="AGPL-3.0"
ENV LANG=C.UTF-8 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
HOME=/home/appuser
# Patch OS packages, then install runtime deps.
# tor package creates its own tor user/group and /var/lib/tor
# su-exec for privilege drop in entrypoint
RUN apk upgrade --no-cache \
&& apk add --no-cache tor su-exec
# App user (non-root)
RUN addgroup -g 1000 -S appgroup \
&& adduser -u 1000 -S appuser -G appgroup -h /home/appuser
# Install pinned deps (no build tools needed at runtime)
COPY requirements.lock /app/requirements.lock
RUN pip install --no-deps -r /app/requirements.lock \
&& pip install --upgrade 'pip>=26.1' 'setuptools>=82' 'wheel>=0.46.2'
# Application source (root-owned, read-only for appuser)
WORKDIR /srv/app
COPY --chown=root:root . /srv/app/
# Compile translations (.po → .mo)
RUN python manage_translations.py compile
# Persistent data dir (settings.txt, data/, etc.)
RUN mkdir -p /home/appuser/.yt-local/data \
&& chown -R appuser:appgroup /home/appuser/.yt-local \
&& chmod 750 /home/appuser/.yt-local
VOLUME /home/appuser/.yt-local
# Tor: fix perms on dirs already created by apk
RUN chown tor:tor /var/lib/tor /var/log/tor \
&& chmod 700 /var/lib/tor /var/log/tor
# Entrypoints (root-owned, executable)
COPY --chmod=755 entrypoint.sh entrypoint-tor.sh /
EXPOSE 9010
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD sh -c 'python -c "import urllib.request; urllib.request.urlopen(\"http://127.0.0.1:9010\")"'
ENTRYPOINT ["/entrypoint.sh"]
|