Skip to content

Instantly share code, notes, and snippets.

@oliverjumpertz
Last active December 16, 2020 14:31
Show Gist options
  • Save oliverjumpertz/56499ab6a038214c5aef5ea2e5f03623 to your computer and use it in GitHub Desktop.
Save oliverjumpertz/56499ab6a038214c5aef5ea2e5f03623 to your computer and use it in GitHub Desktop.
A Dockerfile to get your Next.js app containerized.
node_modules/
README.md
FROM node:14-alpine as build
ENV NEXT_TELEMETRY_DISABLED=1
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
COPY . ./
RUN 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 nodejs && \
adduser -S nextjs -u 1001
USER nextjs
EXPOSE 3000
ENTRYPOINT ["yarn", "start"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment