Last active
December 23, 2020 18:27
-
-
Save badsyntax/e9f08706ff8b649675a9232d1ffbc280 to your computer and use it in GitHub Desktop.
Next.js Dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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