# Use Node.js 22 as the base image FROM node:22-alpine # Set working directory WORKDIR /application # Copy package files first COPY package*.json ./ # Install dependencies RUN npm ci # Copy the rest of the application COPY . . # Initialize Prisma RUN npx prisma generate # NOTE: Migrations should be run separately before deployment # DO NOT use 'migrate dev' in production - it creates new migrations # Use 'prisma migrate deploy' instead, run separately before container start # RUN npx prisma migrate deploy # Build the Next.js application RUN npm run build # Expose port 3000 EXPOSE 3000 # Set environment variable ENV NODE_ENV production ENV NEXT_TELEMETRY_DISABLED 1 # Start the application and keep the container running even if it fails CMD ["sh", "-c", "npm start || tail -f /dev/null"]