Skip to content

Instantly share code, notes, and snippets.

@prateekguptaiiitk
Created October 7, 2020 15:56
Show Gist options
  • Save prateekguptaiiitk/630973001e0cadb78714ce27df20e63b to your computer and use it in GitHub Desktop.
Save prateekguptaiiitk/630973001e0cadb78714ce27df20e63b to your computer and use it in GitHub Desktop.
Dockerfile for nextjs apps
FROM node:current-alpine AS base
WORKDIR /base
COPY package*.json ./
RUN npm install
COPY . .
FROM base AS build
ENV NODE_ENV=production
WORKDIR /build
COPY --from=base /base ./
RUN npm run build
FROM node:current-alpine AS production
ENV NODE_ENV=production
WORKDIR /app
COPY --from=build /build/package*.json ./
COPY --from=build /build/.next ./.next
COPY --from=build /build/public ./public
RUN npm install next
EXPOSE 3000
CMD npm run start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment