# Use Node.js 18.17.1 as the base image
FROM node:18.20.7-alpine

# Install Nginx and other dependencies
# RUN apk add --no-cache nginx

# Set the working directory in the container
WORKDIR /app

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

# Install dependencies and PM2 globally
RUN npm install && npm install pm2 -g

# Copy the rest of your app's source code
COPY . .

# Build your Next.js app
RUN npm run build

# Remove the default Nginx configuration file
#RUN rm /etc/nginx/conf.d/default.conf

# Copy a new Nginx configuration file
#COPY nginx.conf /etc/nginx/conf.d/

# Expose port 80 for Nginx
EXPOSE 4200
EXPOSE 3000

CMD [ "pm2-runtime", "start", "npm", "--", "start", "--", "--port=8080" ]

