Skip to content

Instantly share code, notes, and snippets.

@badsyntax
Last active December 23, 2020 18:27
Show Gist options
  • Save badsyntax/e9f08706ff8b649675a9232d1ffbc280 to your computer and use it in GitHub Desktop.
Save badsyntax/e9f08706ff8b649675a9232d1ffbc280 to your computer and use it in GitHub Desktop.
Next.js Dockerfile
FROM node:14.15.3-alpine AS builder
WORKDIR /app
ENV NPM_CONFIG_LOGLEVEL warn
ENV NPM_CONFIG_FUND false
ENV NPM_CONFIG_AUDIT false
ENV CI true
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build
RUN npm prune --production
FROM node:14.15.3-alpine
ENV NPM_CONFIG_LOGLEVEL warn
ENV NODE_ENV production
ENV PORT 3000
WORKDIR /app
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/.next ./.next
COPY public public
EXPOSE 3000
USER node
CMD ["npx", "pm2-runtime", "./node_modules/.bin/next", "--", "start"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment