43 lines
No EOL
1.5 KiB
Docker
43 lines
No EOL
1.5 KiB
Docker
# To use this Dockerfile, you have to set `output: 'standalone'` in your next.config.js file.
|
|
# From https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile
|
|
|
|
FROM oven/bun:1-alpine AS base
|
|
|
|
# Install dependencies only when needed
|
|
FROM base AS deps
|
|
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
|
RUN apk add --no-cache libc6-compat
|
|
WORKDIR /app
|
|
|
|
ARG FONTAWESOME_PACKAGE_TOKEN
|
|
|
|
# Install dependencies based on the preferred package manager
|
|
COPY package.json bun.lock* ./
|
|
RUN \
|
|
if [ -n "$FONTAWESOME_PACKAGE_TOKEN" ]; then \
|
|
printf "@fortawesome:registry=https://npm.fontawesome.com/\n@awesome.me:registry=https://npm.fontawesome.com/\n//npm.fontawesome.com/:_authToken=%s\n" "$FONTAWESOME_PACKAGE_TOKEN" > .npmrc; \
|
|
fi; \
|
|
bun install --frozen-lockfile; \
|
|
rm -f .npmrc
|
|
|
|
# Copy package files and install dependencies with Bun
|
|
COPY package.json bun.lockb ./
|
|
RUN bun install --frozen-lockfile
|
|
|
|
# Copy the rest of the app source and build it
|
|
COPY . .
|
|
RUN bun run build
|
|
|
|
# Stage 2: The Runner (using Node)
|
|
FROM node:20-alpine as runner
|
|
WORKDIR /app
|
|
|
|
# Only copy what's necessary for production from the builder stage
|
|
COPY --from=base /app/.next ./.next
|
|
COPY --from=base /app/node_modules ./node_modules
|
|
COPY --from=base /app/package.json ./package.json
|
|
COPY --from=base /app/public ./public
|
|
|
|
# Expose port and define command to run the app with Node
|
|
EXPOSE 3000
|
|
CMD ["node_modules/.bin/next", "start"] |