-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (48 loc) · 2.08 KB
/
Copy pathDockerfile
File metadata and controls
65 lines (48 loc) · 2.08 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
# syntax = docker/dockerfile:1
# Adjust NODE_VERSION as desired.
# Must be >= 22.0.0: yt-dlp's EJS YouTube signature/n-challenge solver requires
# a Node >= 22 runtime (or Deno). On Node 20 the solver fails and YouTube returns
# only storyboard images, surfacing as "Requested format is not available".
ARG NODE_VERSION=22.23.0
FROM node:${NODE_VERSION}-slim as base
LABEL fly_launch_runtime="Node.js"
# Node.js app lives here
WORKDIR /app
# Set production environment
ENV NODE_ENV="production"
# Throw-away build stage to reduce size of final image
FROM base as build
# Install packages needed to build node modules
RUN apt-get update -qq && \
apt-get install -y build-essential pkg-config python-is-python3
# Install node modules
COPY --link package-lock.json package.json ./
RUN npm ci
# Copy application code
COPY --link . .
# Final stage for app image
FROM base
# Bootstrap yt-dlp (fallback if startup upgrade fails). docker-entrypoint.sh upgrades
# to GitHub latest on each machine start when the version differs.
ARG YTDLP_VERSION=2026.03.17
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends curl ca-certificates ffmpeg && \
curl -fSL "https://github.com/yt-dlp/yt-dlp/releases/download/${YTDLP_VERSION}/yt-dlp_linux" \
-o /usr/local/bin/yt-dlp && \
chmod a+rx /usr/local/bin/yt-dlp && \
yt-dlp --version && \
rm -rf /var/lib/apt/lists/*
# Deno is yt-dlp's recommended (sandboxed) runtime for solving YouTube's
# signature/n-challenges. Preferring it keeps challenge-solving working
# independently of the app's Node version. Node 22 (the base image) stays as a
# fallback runtime via YTDLP_JS_RUNTIME below.
COPY --from=denoland/deno:bin /deno /usr/local/bin/deno
RUN chmod a+rx /usr/local/bin/deno && deno --version
ENV YTDLP_JS_RUNTIME=deno,node
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN sed -i 's/\r$//' /usr/local/bin/docker-entrypoint.sh && \
chmod +x /usr/local/bin/docker-entrypoint.sh
# Copy built application
COPY --from=build /app /app
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD [ "npm", "run", "start" ]