-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Docker example using bun #83040
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
Merged
Merged
Docker example using bun #83040
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3bb6ffa
docs (examples): add `Dockerfile` for `bun`
JakobKlotz cf4d518
docs (examples): add instructions for `bun`
JakobKlotz 094484f
docs (examples): fix multi-line ENV statement
JakobKlotz 53ba60f
Merge branch 'canary' into docker-examples
icyJoseph 7e11fb1
docs (examples): remove creation of next.config.js for more consistency
JakobKlotz a7936a2
fix (examples): replace `node` with `bun` as runtime
JakobKlotz a8f1ab0
docs (examples): revert list numbering change
JakobKlotz 77c9127
Update examples/with-docker/README.md
JakobKlotz 6cae383
Update examples/with-docker/Dockerfile.bun
JakobKlotz 1ac4772
Merge branch 'canary' into docker-examples
icyJoseph dd6c3b2
Update examples/with-docker/README.md
icyJoseph 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 |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # ----------------------------------------------------------------------------- | ||
| # This Dockerfile.bun is specifically configured for projects using Bun | ||
| # For npm/pnpm or yarn, refer to the Dockerfile instead | ||
| # ----------------------------------------------------------------------------- | ||
|
|
||
| # Use Bun's official image | ||
| FROM oven/bun:1 AS base | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Install dependencies with bun | ||
| FROM base AS deps | ||
| COPY package.json bun.lock* ./ | ||
JakobKlotz marked this conversation as resolved.
Show resolved
Hide resolved
JakobKlotz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| RUN bun install --no-save --frozen-lockfile | ||
|
|
||
| # Rebuild the source code only when needed | ||
| FROM base AS builder | ||
| WORKDIR /app | ||
| COPY --from=deps /app/node_modules ./node_modules | ||
| COPY . . | ||
|
|
||
| # Next.js collects completely anonymous telemetry data about general usage. | ||
| # Learn more here: https://nextjs.org/telemetry | ||
| # Uncomment the following line in case you want to disable telemetry during the build. | ||
| # ENV NEXT_TELEMETRY_DISABLED=1 | ||
|
|
||
| RUN bun run build | ||
|
|
||
| # Production image, copy all the files and run next | ||
| FROM base AS runner | ||
| WORKDIR /app | ||
|
|
||
| # Uncomment the following line in case you want to disable telemetry during runtime. | ||
| # ENV NEXT_TELEMETRY_DISABLED=1 | ||
|
|
||
| ENV NODE_ENV=production \ | ||
| PORT=3000 \ | ||
| HOSTNAME="0.0.0.0" | ||
|
|
||
| RUN addgroup --system --gid 1001 nodejs && \ | ||
| adduser --system --uid 1001 nextjs | ||
JakobKlotz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| COPY --from=builder /app/public ./public | ||
|
|
||
| # Automatically leverage output traces to reduce image size | ||
| # https://nextjs.org/docs/advanced-features/output-file-tracing | ||
| COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ | ||
| COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static | ||
|
|
||
| USER nextjs | ||
|
|
||
| EXPOSE 3000 | ||
|
|
||
| CMD ["bun", "./server.js"] | ||
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.