Skip to content

Instantly share code, notes, and snippets.

@nilsandrey
Last active December 17, 2020 20:13
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nilsandrey/f2bd69deeeca4e0b5c6843e5bf0a293d to your computer and use it in GitHub Desktop.
Save nilsandrey/f2bd69deeeca4e0b5c6843e5bf0a293d to your computer and use it in GitHub Desktop.
Dockerfile to containerize a Next.js app by @oliverjumpertz@twitter
FROM node: 14-alpine as build
ENV NEXT_TELEMETRY_DISABLED=1
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY ..
RUN yarn install && \
yarn build
FROM node: 14-alpine
ENV NEXT_TELEMETRY_DISABLED=1
WORKDIR /app
COPY --from=build /app/package.json /app/yarn.lock /app/next.config.js
COPY --from=build /app/node_modules/ ./node_modules
COPY --from=build /app/.next/ ./.next
RUN addgroup -g 1001 -S node js && \
adduser -S next js -u 1001
USER nextjs
EXPOSE 3000
ENTRYPOINT ["yarn" , "start"]
@manuschillerdev
Copy link

Thanks for sharing! Seems you missed the underscores in the env var though :)

@nilsandrey
Copy link
Author

nilsandrey commented Dec 17, 2020

Right! Fixed, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment