From 573f50acc1a95fb9c99df82ec750040db8ec7b41 Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 5 Aug 2025 21:54:02 +0300 Subject: [PATCH] feat: add Dockerfile for multi-stage build and remove global stylesheet link --- Dockerfile | 48 ++++++++++++++++++++++++++++++++++++++++++++++ src/app/layout.tsx | 4 ---- 2 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f4bc908 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,48 @@ +FROM node:18-alpine AS base + +# Install dependencies only when needed +FROM base AS deps +# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. +RUN apk add --no-cache libc6-compat +WORKDIR /app + +RUN corepack enable +COPY .yarn ./.yarn +COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .yarnrc.yml ./ + +RUN yarn --frozen-lockfile + + +# Rebuild the source code only when needed +FROM base AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +ENV NEXT_TELEMETRY_DISABLED=1 + +RUN yarn build + +# Production image, copy all the files and run next +FROM base AS runner +WORKDIR /app + +ENV NODE_ENV=production +ENV NEXT_TELEMETRY_DISABLED=1 + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +COPY --from=builder /app/public ./public + +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static + +USER nextjs + +EXPOSE 3000 + +ENV PORT=3000 + +ENV HOSTNAME="0.0.0.0" +CMD ["node", "server.js"] diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 7d90a84..a3900ab 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -40,10 +40,6 @@ export default function RootLayout({ children }: Props) { rel="shortcut icon" href="/favicon.svg" /> -