FROM node:18-slim

# Install dependencies for Puppeteer and FFmpeg
RUN apt-get update && apt-get install -y wget gnupg \
    && apt-get install -y \
    ca-certificates \
    fonts-liberation \
    libappindicator3-1 \
    libasound2 \
    libatk-bridge2.0-0 \
    libatk1.0-0 \
    libcups2 \
    libdbus-1-3 \
    libdrm2 \
    libgbm1 \
    libnspr4 \
    libnss3 \
    libxcomposite1 \
    libxdamage1 \
    libxrandr2 \
    xdg-utils \
    ffmpeg \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR /usr/src/app

# Change ownership of the working directory
RUN chown -R node:node /usr/src/app

# Switch to the 'node' user
USER node

# Copy package.json and package-lock.json to the container
COPY --chown=node:node package*.json ./

# Install project dependencies
RUN npm install

# Copy the rest of your application files into the container
COPY --chown=node:node . .

# Run the script
CMD ["node", "record_video.js"]

