perf: static ffmpeg binary statt apt-get install (~600MB gespart)
- Neuer multi-stage: ffmpeg-fetch laedt statisch gelinkte ffmpeg/ffprobe Binary - Quelle: yt-dlp/FFmpeg-Builds (GPL, alle Codecs enthalten) - Runtime braucht kein apt-get install ffmpeg mehr (kein libavcodec etc.) - curl wird nach yt-dlp Download wieder entfernt (apt purge) - Erwartete Image-Groesse: ~280MB statt ~890MB
This commit is contained in:
parent
901f0bf1dd
commit
4884691e7d
1 changed files with 10 additions and 7 deletions
17
Dockerfile
17
Dockerfile
|
|
@ -24,6 +24,10 @@ RUN npm run build
|
||||||
# Nur Prod-Dependencies für Runtime behalten. rm -rf and cleanly install to prevent npm prune bugs
|
# Nur Prod-Dependencies für Runtime behalten. rm -rf and cleanly install to prevent npm prune bugs
|
||||||
RUN rm -rf node_modules && npm install --omit=dev --no-audit --no-fund
|
RUN rm -rf node_modules && npm install --omit=dev --no-audit --no-fund
|
||||||
|
|
||||||
|
# --- Static ffmpeg binary (kein apt-get, keine Codec-Libs noetig) ---
|
||||||
|
FROM debian:bookworm-slim AS ffmpeg-fetch
|
||||||
|
RUN apt-get update && apt-get install -y curl xz-utils ca-certificates && rm -rf /var/lib/apt/lists/* && curl -L https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz -o /tmp/ffmpeg.tar.xz && mkdir -p /tmp/ffmpeg && tar -xJf /tmp/ffmpeg.tar.xz -C /tmp/ffmpeg --strip-components=2 --wildcards '*/bin/ffmpeg' '*/bin/ffprobe' && chmod +x /tmp/ffmpeg/ffmpeg /tmp/ffmpeg/ffprobe && rm /tmp/ffmpeg.tar.xz
|
||||||
|
|
||||||
# --- Runtime image ---
|
# --- Runtime image ---
|
||||||
FROM node:24-slim AS runtime
|
FROM node:24-slim AS runtime
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
@ -31,10 +35,12 @@ ENV NODE_ENV=production
|
||||||
ENV PORT=8080
|
ENV PORT=8080
|
||||||
ENV SOUNDS_DIR=/data/sounds
|
ENV SOUNDS_DIR=/data/sounds
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y ffmpeg curl ca-certificates && rm -rf /var/lib/apt/lists/* \
|
# Nur ca-certificates fuer HTTPS + yt-dlp (kein ffmpeg via apt!)
|
||||||
&& curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp \
|
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl && curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp && chmod a+rx /usr/local/bin/yt-dlp && apt-get purge -y curl && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*
|
||||||
&& chmod a+rx /usr/local/bin/yt-dlp \
|
|
||||||
&& yt-dlp --version || true
|
# Statische ffmpeg/ffprobe Binaries aus fetch-stage kopieren
|
||||||
|
COPY --from=ffmpeg-fetch /tmp/ffmpeg/ffmpeg /usr/local/bin/ffmpeg
|
||||||
|
COPY --from=ffmpeg-fetch /tmp/ffmpeg/ffprobe /usr/local/bin/ffprobe
|
||||||
|
|
||||||
COPY --from=server-build /app/server/dist ./server/dist
|
COPY --from=server-build /app/server/dist ./server/dist
|
||||||
COPY --from=server-build /app/server/node_modules ./server/node_modules
|
COPY --from=server-build /app/server/node_modules ./server/node_modules
|
||||||
|
|
@ -44,6 +50,3 @@ COPY --from=web-build /app/web/dist ./web/dist
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
VOLUME ["/data/sounds"]
|
VOLUME ["/data/sounds"]
|
||||||
CMD ["node", "server/dist/index.js"]
|
CMD ["node", "server/dist/index.js"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue