Add Dockerfile (#4)

This commit is contained in:
Kiran K 2022-03-01 03:23:55 +05:30 committed by GitHub
parent e10609c56b
commit 1f6b8fcc85
2 changed files with 41 additions and 0 deletions

8
.dockerignore Normal file
View File

@ -0,0 +1,8 @@
node_modules
npm-debug.log
.git
.github
.vscode
*Dockerfile*
.env
.env.example

33
Dockerfile Normal file
View File

@ -0,0 +1,33 @@
FROM node:16.14.0-alpine3.15 AS base
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install
FROM base 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 base AS runner
WORKDIR /app
ENV NODE_OPTIONS="--max-http-header-size=81920"
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 4000
CMD ["npm", "start"]