-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix: Docker build failure - Unable to locate package nodejs #409
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,14 +1,20 @@ | ||||||||||||||||||||
| FROM nginx:1.23.0 | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # Update apt and install required packages | ||||||||||||||||||||
| RUN apt-get update && apt-get upgrade -y | ||||||||||||||||||||
|
|
||||||||||||||||||||
| RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - | ||||||||||||||||||||
| RUN apt-get install -y nodejs | ||||||||||||||||||||
| # Install Node.js using NodeSource - run apt-get update after setup script | ||||||||||||||||||||
| # The setup script adds the NodeSource repository but apt cache may be stale | ||||||||||||||||||||
| RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ | ||||||||||||||||||||
|
||||||||||||||||||||
| && apt-get update \ | ||||||||||||||||||||
| && apt-get install -y nodejs | ||||||||||||||||||||
|
||||||||||||||||||||
| && apt-get install -y nodejs | |
| && apt-get install -y nodejs \ | |
| && apt-get clean \ | |
| && rm -rf /var/lib/apt/lists/* |
Copilot
AI
Jan 30, 2026
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 apt-get update command here is redundant. The NodeSource setup script (setup_18.x) already runs apt-get update as part of its execution. This adds unnecessary time to the Docker build. Consider removing this line to optimize the build process.
| # Install Node.js using NodeSource - run apt-get update after setup script | |
| # The setup script adds the NodeSource repository but apt cache may be stale | |
| RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ | |
| && apt-get update \ | |
| && apt-get install -y nodejs | |
| # Install Node.js using NodeSource | |
| # The setup script adds the NodeSource repository and runs apt-get update | |
| RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ | |
| && apt-get install -y nodejs |
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.
Following Docker best practices and for consistency with lines 16-17, consider adding
apt-get cleanandrm -rf /var/lib/apt/lists/*at the end of this RUN command to reduce the image layer size. This helps minimize the final Docker image size by removing the apt package cache after upgrades.