FROM node:20-alpine

# Install Nginx to serve static frontend
RUN apk add --no-cache nginx

WORKDIR /app

# Copy application files
COPY index.html /usr/share/nginx/html/index.html
COPY generate-meet.js /app/generate-meet.js

# Configure Nginx default site to serve index.html on port 80
RUN echo 'server { \
    listen 80; \
    location / { \
        root /usr/share/nginx/html; \
        index index.html; \
    } \
}' > /etc/nginx/http.d/default.conf

# Expose HTTP frontend port (80) and Backend API port (8585)
EXPOSE 80 8585

# Launch Nginx in background and run Node backend on port 8585
CMD ["sh", "-c", "nginx && node /app/generate-meet.js 8585"]