Dockerfile: add from_source version as reference

This commit is contained in:
2025-02-22 01:10:07 -08:00
parent 4d4b26e105
commit 0ec6c2e3b3

110
Dockerfile.from_source Normal file
View File

@@ -0,0 +1,110 @@
ARG YTDLP_VERSION='2024.03.10'
ARG MPV_VERSION='0.39'
# Build stage for Node.js application
FROM --platform=$TARGETPLATFORM node:23-alpine AS node-builder
WORKDIR /app
# Copy package files
COPY package*.json ./
COPY frontend/package*.json ./frontend/
# Install dependencies
RUN npm ci
RUN cd frontend && npm ci
# Copy source files
COPY . .
# Build frontend and backend
RUN npm run build
# Build stage for mpv
FROM --platform=$TARGETPLATFORM alpine AS mpv-builder
# Install build dependencies for mpv
RUN apk add --no-cache \
git \
python3 \
python3-dev \
py3-pip \
meson \
ninja \
pkgconfig \
gcc \
g++ \
musl-dev \
make \
ffmpeg-dev \
mesa-dev \
alsa-lib-dev \
libplacebo-dev \
libass-dev \
lua \
lua-dev \
pulseaudio-dev
# Clone and build mpv
ARG MPV_VERSION
WORKDIR /src
RUN git clone --depth 1 -b release/${MPV_VERSION} https://github.com/mpv-player/mpv.git && \
cd mpv && \
meson setup build --prefix=/tmp/mpv-prefix && \
meson compile -C build && \
meson install -C build && \
tar -czf /tmp/mpv-install.tar.gz -C /tmp/mpv-prefix .
# Build stage for yt-dlp
FROM --platform=$TARGETPLATFORM python:3.11-alpine AS ytdlp-builder
# Install build dependencies for yt-dlp
RUN apk add --no-cache \
git \
make \
py3-pip \
python3-dev \
gcc \
musl-dev
# Clone and build yt-dlp
ARG YTDLP_VERSION
WORKDIR /build
RUN git clone https://github.com/yt-dlp/yt-dlp.git --single-branch --branch ${YTDLP_VERSION} .
RUN python3 devscripts/install_deps.py --include pyinstaller
RUN python3 devscripts/make_lazy_extractors.py
RUN python3 -m bundle.pyinstaller --name=yt-dlp
# Production stage
FROM --platform=$TARGETPLATFORM alpine:latest
# Install runtime dependencies
RUN apk add --no-cache \
python3 \
ffmpeg \
mesa \
alsa-lib \
pulseaudio \
pulseaudio-utils \
libstdc++ \
ca-certificates \
npm
WORKDIR /app
# Install only production dependencies for Node.js
COPY package*.json ./
RUN npm ci --production
# Copy built files from previous stages
COPY --from=node-builder /app/build ./build
COPY --from=node-builder /app/frontend/dist ./dist/frontend
COPY --from=ytdlp-builder /build/dist/yt-dlp /usr/bin/
COPY --from=mpv-builder /tmp/mpv-install.tar.gz /tmp/
RUN tar -xzf /tmp/mpv-install.tar.gz -C / && \
rm /tmp/mpv-install.tar.gz
EXPOSE 3000
CMD ["node", "build/server.js"]