From 0efb827db91bf8d37666467346b0ab496c29e7ca Mon Sep 17 00:00:00 2001 From: Yash <78804783+yashd-dev@users.noreply.github.com> Date: Mon, 14 Oct 2024 21:17:10 +0530 Subject: [PATCH] fix: fixing docker image --- Dockerfile | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index aab80cc..6df2b9a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,37 +1,24 @@ # Use Node.js 18 Alpine as the base image -FROM node:18-alpine AS base +FROM node:18-alpine -# Install dependencies only when needed -FROM base AS deps -# Add libc6-compat for Alpine compatibility -RUN apk add --no-cache libc6-compat +# Set working directory WORKDIR /app -# Copy package files to set up dependencies -COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ -RUN \ - if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ - elif [ -f package-lock.json ]; then npm ci; \ - elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \ - else echo "Lockfile not found." && exit 1; \ - fi - -# Build the application -FROM base AS builder -WORKDIR /app -COPY --from=deps /app/node_modules ./node_modules +# Copy all files to the working directory COPY . . -RUN npm run build -ENV NODE_ENV production +# Install dependencies +RUN npm ci -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 nextjs -USER nextjs +# Build the application +RUN npm run build -EXPOSE 3004 +# Expose the port the app runs on +EXPOSE 3000 +# Set environment variables ENV PORT 3000 ENV HOSTNAME "0.0.0.0" -# Start the Next.js application -CMD ["npm", "run", "start"] \ No newline at end of file + +# Start the application +CMD ["npm", "start"] \ No newline at end of file