Last active
November 21, 2021 14:54
-
-
Save bdcorps/93391bd9c6afce88aa59d5d2876ae5e7 to your computer and use it in GitHub Desktop.
Dockerfile for Next.js project
This file contains 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
# Adapted from https://nextjs.org/docs/deployment | |
FROM node:16-alpine AS deps | |
RUN apk add --no-cache libc6-compat | |
WORKDIR /app | |
COPY package.json ./ | |
RUN npm install | |
FROM node:16-alpine AS builder | |
WORKDIR /app | |
COPY . . | |
COPY --from=deps /app/node_modules ./node_modules | |
RUN npm run build && npm install --production --ignore-scripts --prefer-offline | |
FROM node:16-alpine AS runner | |
WORKDIR /app | |
ENV NODE_ENV production | |
RUN addgroup -g 1001 -S nodejs | |
RUN adduser -S nextjs -u 1001 | |
COPY --from=builder /app/public ./public | |
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next | |
COPY --from=builder /app/node_modules ./node_modules | |
COPY --from=builder /app/package.json ./package.json | |
USER nextjs | |
EXPOSE 3007 | |
ENV PORT 3007 | |
CMD ["npm", "start"] |
This file contains 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
{ | |
"name": "my-app", | |
"version": "0.1.0", | |
"private": true, | |
"scripts": { | |
"dev": "next dev -p 3007", | |
"build": "next build", | |
"start": "next start -p 3007", | |
}, | |
"dependencies": { | |
"axios": "^0.21.1", | |
"bootstrap": "^4.6.0", | |
"next": "^10.0.7", | |
"react": "17.0.1", | |
"react-bootstrap": "^1.5.0", | |
"react-dom": "17.0.1" | |
}, | |
"devDependencies": { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment