-
Notifications
You must be signed in to change notification settings - Fork 60.8k
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
Open
wixxidevelop
wants to merge
1
commit into
ChatGPTNextWeb:main
Choose a base branch
from
wixxidevelop:patch-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Update Dockerfile #6550
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,57 +1,79 @@ | ||
| FROM node:18-alpine AS base | ||
|
|
||
| # Install dependencies only when needed | ||
| FROM base AS deps | ||
|
|
||
| RUN apk add --no-cache libc6-compat | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY package.json yarn.lock ./ | ||
| # Copy package files | ||
| COPY package.json yarn.lock* ./ | ||
|
|
||
| RUN yarn config set registry 'https://registry.npmmirror.com/' | ||
| RUN yarn install | ||
| # Configure yarn and install dependencies | ||
| RUN yarn config set registry 'https://registry.npmmirror.com/' && \ | ||
| yarn install --frozen-lockfile | ||
|
|
||
| # Rebuild the source code only when needed | ||
| FROM base AS builder | ||
|
|
||
| RUN apk update && apk add --no-cache git | ||
|
|
||
| ENV OPENAI_API_KEY="" | ||
| ENV GOOGLE_API_KEY="" | ||
| ENV CODE="" | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Copy node_modules from deps stage | ||
| COPY --from=deps /app/node_modules ./node_modules | ||
| COPY . . | ||
|
|
||
| # Set build-time environment variables | ||
| ENV NEXT_TELEMETRY_DISABLED 1 | ||
| ENV NODE_ENV production | ||
|
|
||
| # Build the application | ||
| RUN yarn build | ||
|
|
||
| # Production image, copy all the files and run next | ||
| FROM base AS runner | ||
| WORKDIR /app | ||
|
|
||
| RUN apk add proxychains-ng | ||
| # Install proxychains for proxy support | ||
| RUN apk add --no-cache proxychains-ng | ||
|
|
||
| # Set runtime environment | ||
| ENV NODE_ENV production | ||
| ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
|
||
| # Environment variables (will be overridden at runtime) | ||
| ENV PROXY_URL="" | ||
| ENV OPENAI_API_KEY="" | ||
| ENV GOOGLE_API_KEY="" | ||
| ENV CODE="" | ||
| ENV ENABLE_MCP="" | ||
|
|
||
| # Create a non-root user | ||
| RUN addgroup --system --gid 1001 nodejs && \ | ||
| adduser --system --uid 1001 nextjs | ||
|
|
||
| # Copy built application | ||
| 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 | ||
|
|
||
| RUN mkdir -p /app/app/mcp && chmod 777 /app/app/mcp | ||
| # Create and set up MCP directory | ||
| RUN mkdir -p /app/app/mcp && \ | ||
| chmod 777 /app/app/mcp | ||
|
Comment on lines
+59
to
+60
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
World-writable permissions on -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 |
||
| COPY --from=builder /app/app/mcp/mcp_config.default.json /app/app/mcp/mcp_config.json | ||
|
|
||
| # Switch to non-root user | ||
| USER nextjs | ||
|
|
||
| EXPOSE 3000 | ||
|
|
||
| ENV PORT 3000 | ||
| ENV HOSTNAME "0.0.0.0" | ||
|
|
||
| # Start the application | ||
| CMD if [ -n "$PROXY_URL" ]; then \ | ||
| export HOSTNAME="0.0.0.0"; \ | ||
| protocol=$(echo $PROXY_URL | cut -d: -f1); \ | ||
| host=$(echo $PROXY_URL | cut -d/ -f3 | cut -d: -f1); \ | ||
| port=$(echo $PROXY_URL | cut -d: -f3); \ | ||
| conf=/etc/proxychains.conf; \ | ||
| conf=/tmp/proxychains.conf; \ | ||
| echo "strict_chain" > $conf; \ | ||
| echo "proxy_dns" >> $conf; \ | ||
| echo "remote_dns_subnet 224" >> $conf; \ | ||
|
|
@@ -61,7 +83,6 @@ CMD if [ -n "$PROXY_URL" ]; then \ | |
| echo "localnet ::1/128" >> $conf; \ | ||
| echo "[ProxyList]" >> $conf; \ | ||
| echo "$protocol $host $port" >> $conf; \ | ||
| cat /etc/proxychains.conf; \ | ||
| proxychains -f $conf node server.js; \ | ||
| else \ | ||
| node server.js; \ | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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/publicremains root-ownedThe
.nextartifacts are correctly--chowned, butpublic/is copied without ownership override. Running as thenextjsuser may fail if the app needs to write (e.g. logs, uploads) insidepublic.π€ Prompt for AI Agents