Skip to content

Instantly share code, notes, and snippets.

@tarex
Forked from kandros/.dockerignore
Created December 16, 2020 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarex/ce210f4fb101a941d7bab0dce11fb315 to your computer and use it in GitHub Desktop.
Save tarex/ce210f4fb101a941d7bab0dce11fb315 to your computer and use it in GitHub Desktop.
Dockerfile for next.js projects
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 prod_node_modules
RUN yarn --frozen-lockfile --silent
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 /app/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