Last active
December 16, 2020 14:31
-
-
Save oliverjumpertz/56499ab6a038214c5aef5ea2e5f03623 to your computer and use it in GitHub Desktop.
A Dockerfile to get your Next.js app containerized.
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
node_modules/ | |
README.md |
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-alpine as build | |
ENV NEXT_TELEMETRY_DISABLED=1 | |
RUN apk add --no-cache libc6-compat | |
WORKDIR /app | |
COPY package.json yarn.lock ./ | |
RUN yarn install --frozen-lockfile | |
COPY . ./ | |
RUN yarn build | |
FROM node:14-alpine | |
ENV NEXT_TELEMETRY_DISABLED=1 | |
WORKDIR /app | |
COPY --from=build /app/package.json /app/yarn.lock /app/next.config.js ./ | |
COPY --from=build /app/node_modules/ ./node_modules | |
COPY --from=build /app/.next/ ./.next | |
RUN addgroup -g 1001 -S nodejs && \ | |
adduser -S nextjs -u 1001 | |
USER nextjs | |
EXPOSE 3000 | |
ENTRYPOINT ["yarn", "start"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment