# Use the official Playwright image which includes all browser dependencies
FROM mcr.microsoft.com/playwright:v1.57.0-jammy

# Set working directory
WORKDIR /app

# Copy package files
COPY package*.json ./

# Install dependencies (including devDependencies for building)
RUN npm ci

# Copy source code
COPY . .

# Build the TypeScript project
RUN npm run build

# Prune dev dependencies to reduce image size (optional, but good practice)
# Note: we need to keep some deps if they are runtime requirements
# npm prune --production

# Create data directory
RUN mkdir -p data

# Expose the port defined in config (default 3000)
EXPOSE 3000

# Start the application using the compiled code
CMD ["node", "dist/index.js"]
