FROM ubuntu:24.04

RUN apt-get update
RUN apt-get install git curl make -y
RUN curl -fsSL https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s 20
WORKDIR /usr/app
RUN npm i -g @remotion/cli
RUN apt install -y \
  libnss3 \
  libdbus-1-3 \
  libatk1.0-0 \
  libasound2t64 \
  libxrandr2 \
  libxkbcommon-dev \
  libxfixes3 \
  libxcomposite1 \
  libxdamage1 \
  libgbm-dev \
  libcups2 \
  libcairo2 \
  libpango-1.0-0 \
  libatk-bridge2.0-0

COPY ensure-browser.mjs .
COPY ensure.mjs .
RUN node ensure.mjs

# Copy the pre-built bundle
COPY bundle/ /usr/app/bundle/

RUN npx remotion compositions /usr/app/bundle
RUN npx remotion render /usr/app/bundle browser-test /usr/app/out.mp4 --log=verbose