-
Notifications
You must be signed in to change notification settings - Fork 61.1k
Update Dockerfile #6550
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: main
Are you sure you want to change the base?
Update Dockerfile #6550
Conversation
WalkthroughThe Dockerfile was refactored to streamline the multi-stage build process, clarify dependency installation, and enhance runtime security by using a non-root user. Proxychains configuration was updated to generate its config file in a temporary directory, and environment variable management was improved for both build and runtime stages. Changes
Poem
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. πͺ§ TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 2
π§Ή Nitpick comments (3)
Dockerfile (3)
11-13
: Avoid hard-coding Yarn registry; make it configurablePinning the registry to
registry.npmmirror.com
can break CI/CD when the mirror is unavailable or slow and may raise supply-chain concerns. Prefer reading the registry from an ARG/ENV (falling back to npmjs) so image consumers can override it.- RUN yarn config set registry 'https://registry.npmmirror.com/' && \ - yarn install --frozen-lockfile +ARG YARN_REGISTRY=https://registry.npmjs.org/ +RUN yarn config set registry "${YARN_REGISTRY}" && \ + yarn install --frozen-lockfile
17-17
:apk update
bloats the layer
apk add --no-cache
already refreshes indexes; the explicitapk update
creates an extra layer and cannot be cleaned up, increasing image size.-RUN apk update && apk add --no-cache git +RUN apk add --no-cache git
71-76
: Proxy URL parsing is brittle
cut
-based splitting fails for URLs containing credentials (http://user:pass@host:8080
) or IPv6 hosts. Consider using a small shell utility (e.g.,busybox wget
βsurlparser
, orawk
) or expect users to provide protocol/host/port separately.No change required if current format is guaranteed, but please double-check.
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (1)
Dockerfile
(1 hunks)
π Additional comments (2)
Dockerfile (2)
68-69
: Overwriting the reservedHOSTNAME
variable is risky
HOSTNAME
is automatically set by Docker to the container ID. Replacing it with"0.0.0.0"
can confuse tooling that relies on the standard meaning (e.g., debuggers, logs). Use a custom variable such asAPP_HOST
.-ENV HOSTNAME "0.0.0.0" +ENV APP_HOST "0.0.0.0"
3-90
: Overall Dockerfile refactor improves build caching and drops root privileges β nice work!
COPY --from=builder /app/public ./public | ||
COPY --from=builder /app/.next/standalone ./ | ||
COPY --from=builder /app/.next/static ./.next/static | ||
COPY --from=builder /app/.next/server ./.next/server | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static |
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.
π οΈ Refactor suggestion
Mixed ownership: /app/public
remains root-owned
The .next
artifacts are correctly --chown
ed, but public/
is copied without ownership override. Running as the nextjs
user may fail if the app needs to write (e.g. logs, uploads) inside public
.
-COPY --from=builder /app/public ./public
+COPY --from=builder --chown=nextjs:nodejs /app/public ./public
π€ Prompt for AI Agents
In Dockerfile lines 54 to 56, the COPY command for /app/public does not specify
ownership, leaving it root-owned, while the .next artifacts are copied with
--chown=nextjs:nodejs. To fix this, add --chown=nextjs:nodejs to the COPY
command for /app/public to ensure consistent ownership and prevent permission
issues when the app runs as the nextjs user.
RUN mkdir -p /app/app/mcp && \ | ||
chmod 777 /app/app/mcp |
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.
chmod 777
opens a security hole
World-writable permissions on /app/app/mcp
allow any process (including a breakout) full control. Limit access to the application user.
-RUN mkdir -p /app/app/mcp && \
- chmod 777 /app/app/mcp
+RUN install -d -o nextjs -g nodejs -m 775 /app/app/mcp
π€ Prompt for AI Agents
In Dockerfile lines 59 to 60, the directory /app/app/mcp is given world-writable
permissions with chmod 777, which is a security risk. Change the permissions to
restrict access only to the application user by setting more restrictive
permissions such as 755 or 700, depending on the needed access, and ensure the
directory ownership is assigned to the application user instead of allowing all
users full control.
π» εζ΄η±»ε | Change Type
π εζ΄θ―΄ζ | Description of Change
π θ‘₯ε δΏ‘ζ― | Additional Information
Summary by CodeRabbit