Skip to content

fix(docker): use Debian-provided Node.js instead of NodeSource#518

Open
raystone06 wants to merge 1 commit into
AsyncFuncAI:mainfrom
raystone06:fix/dockerfile-nodesource-tls
Open

fix(docker): use Debian-provided Node.js instead of NodeSource#518
raystone06 wants to merge 1 commit into
AsyncFuncAI:mainfrom
raystone06:fix/dockerfile-nodesource-tls

Conversation

@raystone06
Copy link
Copy Markdown

The previous Dockerfile installed Node.js by adding the NodeSource APT repository, which requires fetching the GPG key over HTTPS from deb.nodesource.com during the build. In some network environments this TLS connection fails with:

curl: (35) TLS connect error: error:0A000126:SSL routines::
unexpected eof while reading

Since Debian Trixie (the base of python:3.11-slim) already ships Node.js 20.x in its main repositories, we can install it directly via apt without depending on NodeSource. This makes the build more reliable and removes the gnupg/keyring setup entirely.

The previous Dockerfile installed Node.js by adding the NodeSource
APT repository, which requires fetching the GPG key over HTTPS from
deb.nodesource.com during the build. In some network environments
this TLS connection fails with:

  curl: (35) TLS connect error: error:0A000126:SSL routines::
  unexpected eof while reading

Since Debian Trixie (the base of python:3.11-slim) already ships
Node.js 20.x in its main repositories, we can install it directly
via apt without depending on NodeSource. This makes the build more
reliable and removes the gnupg/keyring setup entirely.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the Dockerfile to install Node.js and npm directly from Debian repositories to bypass NodeSource TLS issues. Feedback indicates that this change results in a version mismatch, as the current base image provides Node.js v18 instead of the required v20. Additionally, it is suggested to remove npm from the final image to optimize size and security, as it is not needed for runtime.

Comment thread Dockerfile
WORKDIR /app

# Install Node.js and npm
# Install Node.js and npm from Debian repos (avoids NodeSource TLS issues)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The PR description states that python:3.11-slim is based on Debian Trixie, but it is currently based on Debian 12 (Bookworm). Consequently, apt-get install nodejs will install Node.js v18, not v20. Since the build stage (node_builder) uses Node.js v20 and the package.json specifies @types/node": "^20", this version mismatch between build and runtime environments could lead to unexpected behavior or runtime errors. If Node.js 20 is strictly required, you may need to use a different installation method or a base image that supports it natively.

Comment thread Dockerfile
Comment on lines +47 to +48
nodejs \
npm \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The npm package is not required in the final runtime image. The application is already built in the node_builder stage, and the start.sh script executes the application using the node binary directly (line 94). Removing npm will significantly reduce the final image size (typically by 200MB+ on Debian) and reduce the attack surface.

    nodejs \

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant