-
-
Notifications
You must be signed in to change notification settings - Fork 157
Expand file tree
/
Copy pathdockerfile
More file actions
104 lines (85 loc) · 4.21 KB
/
Copy pathdockerfile
File metadata and controls
104 lines (85 loc) · 4.21 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
FROM python:3.13-slim
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
nano \
libicu-dev \
ffmpeg \
curl \
unzip \
gosu \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user for security
RUN groupadd -r appuser && \
useradd -r -g appuser -u 1000 -m -d /home/appuser -s /bin/bash appuser
# Bento4 — official prebuilt release (x86_64 Linux)
RUN BENTO4_VERSION="1-6-0-641" && \
BENTO4_DIR="Bento4-SDK-${BENTO4_VERSION}.x86_64-unknown-linux" && \
curl -fsSL "https://www.bok.net/Bento4/binaries/${BENTO4_DIR}.zip" -o /tmp/bento4.zip && \
unzip -q /tmp/bento4.zip -d /tmp/bento4 && \
mkdir -p /home/appuser/.local/bin/binary && \
cp /tmp/bento4/${BENTO4_DIR}/bin/mp4decrypt /home/appuser/.local/bin/binary/mp4decrypt && \
chmod 755 /home/appuser/.local/bin/binary/mp4decrypt && \
rm -rf /tmp/bento4 /tmp/bento4.zip
# Shaka Packager — official prebuilt release (x86_64 Linux)
RUN SHAKA_VERSION="3.9.3" && \
curl -fsSL "https://github.com/shaka-project/shaka-packager/releases/download/v${SHAKA_VERSION}/packager-linux-x64" \
-o /home/appuser/.local/bin/binary/packager && \
chmod 755 /home/appuser/.local/bin/binary/packager
# Docker CLI + Compose plugin — used by the in-app "Update now"
RUN install -m 0755 -d /etc/apt/keyrings && \
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc && \
chmod a+r /etc/apt/keyrings/docker.asc && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo \"$VERSION_CODENAME\") stable" \
> /etc/apt/sources.list.d/docker.list && \
apt-get update && \
apt-get install -y --no-install-recommends docker-ce-cli docker-compose-plugin && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Fix ownership of the entire home directory before switching user
RUN chown -R appuser:appuser /home/appuser/.local
WORKDIR /app
# Install Python dependencies
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY GUI/requirements.txt ./GUI/requirements.txt
RUN pip install --no-cache-dir -r GUI/requirements.txt
# Telegram bot deps (telethon/cryptg)
COPY docker/telegram_bot/requirements.txt ./docker/telegram_bot/requirements.txt
RUN pip install --no-cache-dir -r docker/telegram_bot/requirements.txt
# Copy application code
COPY . .
# Snapshot the default Conf directory so the entrypoint can seed it on first start
# when the Conf volume is empty (e.g., fresh NAS install).
RUN cp -r /app/Conf /app/Conf.defaults
# Snapshot the default binary directory (mp4decrypt, packager)
RUN cp -r /home/appuser/.local/bin/binary /home/appuser/.local/bin/binary.defaults
# Install entrypoint script
COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
# Create required directories and set permissions
# NOTE: the entrypoint runs as root first to handle PUID/PGID remapping,
# so we do not switch to USER appuser here.
RUN mkdir -p /app/Video /app/logs /app/data /app/.cache \
/home/appuser/.config && \
chown -R appuser:appuser /app /home/appuser && \
chmod -R 755 /app /home/appuser
# Set environment variables
ENV PYTHONPATH="/app:${PYTHONPATH}" \
HOME=/home/appuser \
DJANGO_DB_DIR=/app/data \
PYTHONUNBUFFERED=1
# NOTE: no VOLUME directive on purpose. The persistence strategy is declared
# exclusively in docker-compose.yml using NAMED volumes. A VOLUME directive
# here would:
# 1. Create anonymous volumes (random hash names like e93fdjvndss87...) any
# time the image is started without an explicit -v mount for that path,
# and those orphan volumes pile up across rebuilds.
# 2. Snapshot the directory content at build time and overlay it on startup,
# which silently hides image updates inside long-lived volumes.
# Keeping volume management in docker-compose alone makes the setup
# predictable and easy to reset (`docker-compose down -v`).
EXPOSE 8000
# The entrypoint handles PUID/PGID remapping, first-run Conf seeding,
# and Django migrations, then execs the server as appuser via gosu.
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]