Last active
December 17, 2020 09:10
-
-
Save kandros/81285a5c343bd0b5017c2cbdddb4c112 to your computer and use it in GitHub Desktop.
Dockerfile for next.js projects
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
e2e | |
fixtures | |
*.test.* | |
node_modules | |
.next | |
.env | |
Dockerfile | |
.git |
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:15.3.0-alpine3.10 as deps | |
WORKDIR /app | |
COPY package.json yarn.lock ./ | |
RUN yarn --production --silent | |
RUN cp -R node_modules /tmp/prod_node_modules | |
RUN yarn | |
FROM deps as builder | |
WORKDIR /app | |
COPY . . | |
ENV NODE_ENV=production | |
RUN yarn build | |
FROM node:15.3.0-alpine3.10 AS release | |
ENV NODE_ENV=production | |
WORKDIR /app | |
COPY --from=builder /app/next.config.js ./ | |
COPY --from=builder /app/public ./public | |
COPY --from=builder /app/.next ./.next | |
COPY --from=builder /tmp/prod_node_modules ./node_modules | |
COPY --from=builder /app/.env.production ./.env.production | |
COPY --from=builder /app/package.json ./package.json | |
EXPOSE 3000 | |
CMD ["npm", "start"] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment