-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix Dockerfile and set lefthook to not run in prod
- Loading branch information
1 parent
2231865
commit 676f4d7
Showing
2 changed files
with
40 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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,17 +1,51 @@ | ||
FROM imbios/bun-node:20-slim | ||
FROM imbios/bun-node:22-slim AS base | ||
|
||
# Install dependencies only when needed | ||
FROM base AS deps | ||
|
||
WORKDIR /app | ||
|
||
# Install dependencies | ||
COPY package.json bun.lockb ./ | ||
RUN bun install --frozen-lockfile | ||
|
||
RUN bun install --production --frozen-lockfile | ||
|
||
# Rebuild the source code only when needed | ||
FROM base AS builder | ||
WORKDIR /app | ||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY . . | ||
|
||
# Disable telemetry during the build | ||
ENV NEXT_TELEMETRY_DISABLED=1 | ||
ENV SKIP_ENV_VALIDATION=true | ||
|
||
# Build the application | ||
RUN bunx next build | ||
|
||
|
||
# Production image, copy all the files and run next | ||
FROM base AS runner | ||
WORKDIR /app | ||
|
||
ENV NODE_ENV=production | ||
RUN bun run build | ||
ENV NEXT_TELEMETRY_DISABLED=1 | ||
ENV SKIP_ENV_VALIDATION=true | ||
|
||
RUN addgroup --system --gid 1002 nodejs && \ | ||
adduser --system --uid 1002 nextjs | ||
|
||
COPY --from=builder /app/public ./public | ||
|
||
# Set the correct permission for prerender cache | ||
RUN mkdir .next && chown nextjs:nodejs .next | ||
|
||
# Automatically leverage output traces to reduce image size | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static | ||
|
||
USER nextjs | ||
|
||
EXPOSE 3000 | ||
|
||
ENTRYPOINT [ "bun", "run", "start" ] | ||
# server.js is created by next build from the standalone output | ||
CMD ["bun", "run", "server.js"] |
This file contains 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