# Use the official Node.js runtime as the base image
FROM node:18-alpine

# Set the working directory in the container
WORKDIR /app

# Copy package.json and package-lock.json (if available)
COPY package*.json ./

# Install dependencies
RUN npm ci --only=production

# Copy the rest of the application code
COPY . .

# Create next.config.js to ignore ESLint during build
RUN echo "/** @type {import('next').NextConfig} */" > next.config.js && \
    echo "const nextConfig = {" >> next.config.js && \
    echo "  eslint: {" >> next.config.js && \
    echo "    ignoreDuringBuilds: true," >> next.config.js && \
    echo "  }," >> next.config.js && \
    echo "}" >> next.config.js && \
    echo "" >> next.config.js && \
    echo "module.exports = nextConfig" >> next.config.js

# Build the Next.js application
RUN npm run build

# Expose the port that the app runs on
EXPOSE 3000

# Define the command to run the application
CMD ["npm", "run", "dev"]