Skip to content

Instantly share code, notes, and snippets.

@nilsandrey
Last active December 17, 2020 20:13
Show Gist options
  • Select an option

  • Save nilsandrey/f2bd69deeeca4e0b5c6843e5bf0a293d to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown

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

@nilsandrey

nilsandrey commented Dec 17, 2020

Copy link
Copy Markdown
Author

Right! Fixed, thanks.

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