diff --git a/Dockerfile b/Dockerfile index 86b1682..03572e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,49 +1,29 @@ -FROM node:20-alpine AS base +# Use the official Node.js image as the base image +FROM node:lts-alpine -FROM base AS deps -RUN apk add --no-cache libc6-compat +# Set the working directory inside the container WORKDIR /app +# Copy package.json and package-lock.json to the working directory COPY package*.json ./ -RUN npm ci -FROM base AS builder -WORKDIR /app -COPY --from=deps /app/node_modules ./node_modules -COPY . . +# Install dependencies +RUN npm install -ENV NEXT_TELEMETRY_DISABLED 1 +# Copy the rest of the app's source code to the working directory +COPY . . -# Dummy values for the environment variables -ENV AUTH_SECRET="adf" -ENV AUTH_GOOGLE_ID="adf" -ENV AUTH_GOOGLE_SECRET="adf" -ENV DATABASE_URL="postgres://user:password@db:5432/test_db" -ENV RAZORPAY_KEY="adf" -ENV RAZORPAY_SECRET="adf" +ARG AUTH_SECRET="txxx#12" +ENV AUTH_SECRET=$AUTH_SECRET +# Prisma setup RUN npx prisma generate +# Build the Next.js app RUN npm run build -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 ./.next -COPY --from=builder /app/node_modules ./node_modules -COPY --from=builder /app/package.json ./package.json - -USER nextjs - +# Expose the port that the app will run on EXPOSE 3000 -ENV PORT 3000 - -CMD ["npm", "start"] +# Start the app +CMD ["npm", "start"] \ No newline at end of file