# Step 1: Use Node.js official image as base
FROM node:18-alpine AS base

# Step 2: Set working directory inside container
WORKDIR /app

# Step 3: Copy package.json and package-lock.json to container
COPY package*.json ./

# Step 4: Install dependencies
RUN npm install --frozen-lockfile

# Step 5: Copy the rest of the app files to container
COPY . .

# Step 6: Build the Next.js application
RUN npm run build

# Step 7: Expose the port that the Next.js app will run on
EXPOSE 3000
EXPOSE 2368

# Step 8: Set environment variable for production
ENV NODE_ENV=production

# Step 9: Run the application using 'next start'
CMD ["npm", "run", "start"]

