You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to package my blog as a docker container. While researching how to do this I came upon #185 which was asked quite a while ago. A lot has changed in the project since 2021(yarn instead of npm...), so I was wondering if anyone had a working Dockerfile setup for the latest release.
I tried updating the Dockerfile from #185. I also set output in the nextjs config to standalone as per the nextjs docker docs It currently doesn't run because it throws an error that it couldn't find a package. This also happens with a freshly created copy
could not find a copy of esbuild to link in /app/node_modules/@contentlayer/core/node_modules
Dockerfile
# Install dependencies only when needed
FROM node:20-alpine 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
COPY package.json yarn.lock ./
RUN yarn install
# Rebuild the source code only when needed
FROM node:20-alpine AS builder
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules
RUN yarn run build
# Production image, copy all the files and run next
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV production
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nextjs -u 1001
# You only need to copy next.config.js if you are NOT using the default configuration
COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
USER nextjs
EXPOSE 3000
# 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.
ENV NEXT_TELEMETRY_DISABLED 1
CMD ["yarn", "run", "serve"]
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm trying to package my blog as a docker container. While researching how to do this I came upon #185 which was asked quite a while ago. A lot has changed in the project since 2021(yarn instead of npm...), so I was wondering if anyone had a working Dockerfile setup for the latest release.
I tried updating the Dockerfile from #185. I also set
output
in the nextjs config tostandalone
as per the nextjs docker docs It currently doesn't run because it throws an error that it couldn't find a package. This also happens with a freshly created copyDockerfile
Beta Was this translation helpful? Give feedback.
All reactions