From 633503a138e11c7596b96f43266198028c7cc5ae Mon Sep 17 00:00:00 2001 From: StepanovPlaton Date: Sun, 7 Jul 2024 02:09:38 +0400 Subject: [PATCH] Create Dockerfile --- Dockerfile | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ad3d48c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,44 @@ +# https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile + +# Stage 0: Get base system +FROM node:18-alpine AS base + + +# Stage 1: Instal dependencies +FROM base AS dependencies +WORKDIR /application +COPY package.json package-lock.json ./ +RUN npm ci + + +# Stage 2: Build +FROM base AS builder +WORKDIR /application +COPY --from=dependencies /application/node_modules ./node_modules +COPY . . +ENV NEXT_TELEMETRY_DISABLED 1 +RUN npm run build + + +# Stage 3: Start +FROM base AS runner +WORKDIR /application +ENV NODE_ENV production +ENV NEXT_TELEMETRY_DISABLED 1 + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +COPY --from=builder /application/public ./public + +RUN mkdir .next +RUN chown nextjs:nodejs .next +COPY --from=builder --chown=nextjs:nodejs /application/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /application/.next/static ./.next/static + +USER nextjs + +EXPOSE 3000 +ENV PORT 3000 + +CMD HOSTNAME="0.0.0.0" node server.js