FROM node:20-slim

# Install Chrome dependencies and Chrome
RUN apt-get update && apt-get install -y \
  google-chrome-stable \
  fonts-liberation \
  --no-install-recommends \
  && rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY package*.json ./
RUN npm install

COPY . .

RUN npm run build 2>/dev/null || true
RUN node scripts/build-agent-release.js

ENV CHROME_PATH=/usr/bin/google-chrome-stable
ENV PORT=10000

EXPOSE 10000

CMD node migrate.js && node server.js
