-
Notifications
You must be signed in to change notification settings - Fork 1
install node.js in docker container #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
see yt-dlp/yt-dlp#15012 With the release of yt-dlp version 2025.11.12, external JavaScript runtime support has arrived. All users who intend to use yt-dlp with YouTube are strongly encouraged to install one of the supported JS runtimes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds Node.js runtime support to the Docker container to comply with yt-dlp version 2025.11.12 requirements for YouTube downloads. The implementation uses fnm (Fast Node Manager) to install the LTS version of Node.js.
Key Changes:
- Installs Node.js LTS using fnm (Fast Node Manager)
- Changes the default shell to enable fnm's bash login initialization
- Adds the
unzippackage to system dependencies
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| curl -o- https://fnm.vercel.app/install | bash | ||
| SHELL ["/bin/bash", "--login", "-c"] | ||
| RUN fnm install --lts && \ |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SHELL change to use --login shell affects all subsequent RUN commands in the Dockerfile, including the poetry installation at line 34. This could cause unexpected behavior or performance issues as login shells source additional configuration files.
Consider one of these approaches:
- Revert SHELL after the Node.js installation is complete
- Set up fnm's PATH manually without requiring a login shell
- Use a single RUN command with explicit shell invocation for just the fnm commands
Example for approach 2:
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y curl ffmpeg unzip && \
curl -o- https://fnm.vercel.app/install | bash && \
export PATH="/root/.local/share/fnm:$PATH" && \
eval "$(fnm env)" && \
fnm install --lts && \
node -v && npm -v && \
python -m pip install --upgrade pip && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
mkdir /app| curl -o- https://fnm.vercel.app/install | bash | |
| SHELL ["/bin/bash", "--login", "-c"] | |
| RUN fnm install --lts && \ | |
| curl -o- https://fnm.vercel.app/install | bash && \ | |
| export PATH="/root/.local/share/fnm:$PATH" && \ | |
| eval "$(fnm env)" && \ | |
| fnm install --lts && \ |
| RUN fnm install --lts && \ | ||
| node -v && \ | ||
| npm -v && \ | ||
| python -m pip install --upgrade pip && \ | ||
| apt-get install -y curl ffmpeg && \ | ||
| apt-get clean && rm -rf /var/lib/apt/lists/* && \ | ||
| mkdir /app |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Splitting the RUN command into two separate RUN statements creates an additional Docker layer and prevents proper cleanup. The apt-get clean && rm -rf /var/lib/apt/lists/* on line 30 runs in a separate layer from the apt-get install on line 23, so it doesn't actually reduce the image size.
Docker layers are immutable, so removing files in a later layer doesn't remove them from earlier layers. To effectively reduce image size, the installation and cleanup should be in the same RUN command.
Consider combining these RUN commands back together as suggested in the previous comment.
| RUN fnm install --lts && \ | ||
| node -v && \ | ||
| npm -v && \ |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fnm installation adds Node.js to the build environment but doesn't ensure it's available in the runtime environment. The fnm tool modifies the shell's PATH through .bashrc, which works with the --login shell, but this doesn't guarantee Node.js will be available when the container runs the CMD.
To ensure Node.js is available at runtime, add:
ENV PATH="/root/.local/share/fnm:$PATH"after the fnm installation, or configure fnm to install Node.js to a permanent location that's added to the PATH environment variable.
| ENV PH_VIDEO_DURATION=10 | ||
| ENV MEDIA_CHAT_ID=-1002389753204 | ||
| ENV RATE_LIMIT_WINDOW_MINUTES=1 | ||
|
|
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The unzip package is added but there's no clear indication in the PR description or code why it's needed. If it's a dependency for fnm or Node.js installation, please document this in a comment. If it's unrelated to the Node.js installation, consider adding it in a separate commit or PR for clarity.
| # 'unzip' is required for fnm/Node.js installation scripts |
| SHELL ["/bin/bash", "--login", "-c"] | ||
| RUN fnm install --lts && \ | ||
| node -v && \ | ||
| npm -v && \ |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Extra trailing whitespace after npm -v. This should be removed for consistency.
| npm -v && \ | |
| npm -v && \ |
* Revert "install node.js in docker container (#87)" This reverts commit 3784745. * use Deno runtime Adds the Deno runtime to the Docker image. This allows for the execution of Javascript and Typescript code directly within the application's environment. Also installs unzip to allow extraction of zipped files.
see yt-dlp/yt-dlp#15012
With the release of yt-dlp version 2025.11.12, external JavaScript runtime support has arrived.
All users who intend to use yt-dlp with YouTube are strongly encouraged to install one of the supported JS runtimes.