-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdockerfile
More file actions
73 lines (56 loc) · 2.41 KB
/
Copy pathdockerfile
File metadata and controls
73 lines (56 loc) · 2.41 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
FROM node:22 AS builder
WORKDIR /app
# Build-Abhängigkeiten für native Module
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Node Modules mit Build installieren
COPY package*.json ./
RUN npm install --legacy-peer-deps && npm cache clean --force
# === FINAL STAGE ===
FROM node:22
WORKDIR /app
# Runtime-Abhängigkeiten: ffmpeg, python3 + yt-dlp
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
python3-venv \
ffmpeg \
libopus0 \
libsodium23 \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Dedizierter Non-Root-User nach Unraid-Konvention (nobody:users = 99:100).
# Die Gruppe 'users' (gid 100) existiert im Debian-Basis-Image bereits.
RUN useradd --uid 99 --gid 100 --no-create-home --home-dir /app --shell /usr/sbin/nologin musicbot
# Temp-Verzeichnis für Downloads und lokalen Mapping-Ordner erstellen
RUN mkdir -p /tmp/musicbot_downloads /mapping/christ && \
chown -R 99:100 /tmp/musicbot_downloads /mapping
# yt-dlp in Virtual Environment installieren (nur im Container).
# chown im selben Layer: der Entrypoint macht zur Laufzeit
# 'pip install --upgrade' ins venv und braucht dafür Schreibrecht.
RUN python3 -m venv /opt/venv && \
/opt/venv/bin/pip install --no-cache-dir --upgrade pip setuptools wheel && \
/opt/venv/bin/pip install --no-cache-dir yt-dlp && \
chown -R 99:100 /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Node Modules aus Builder kopieren
COPY --from=builder --chown=99:100 /app/node_modules ./node_modules
# Quellcode kopieren
COPY --chown=99:100 package*.json ./
COPY --chown=99:100 . .
# Entrypoint script: fix Windows line endings + make executable
# (sed -i legt die Datei neu an, daher erneut chownen). Zusätzlich /app
# selbst sowie die Mount-Punkte für downloads/logs anlegen und an 99:100
# geben (Bind-Mounts von Unraid-Shares sind dort ebenfalls 99:100).
RUN sed -i 's/\r$//' /app/entrypoint.sh && chmod +x /app/entrypoint.sh && \
chown 99:100 /app/entrypoint.sh && \
mkdir -p /app/downloads /app/logs && \
chown 99:100 /app /app/downloads /app/logs
# Node.js Output unbuffered machen für echte Logs
ENV NODE_OPTIONS=--unhandled-rejections=warn
ENV FORCE_COLOR=1
ENV NODE_BUFFER_SIZE=16777216
# Als Non-Root-User laufen; HOME=/app ist für uid 99 schreibbar (u.a. für pip)
ENV HOME=/app
USER musicbot
ENTRYPOINT ["/app/entrypoint.sh"]