# Use Apify's Node.js 20 base image
FROM apify/actor-node:20

# Copy package files first for better caching
COPY package*.json ./

# Install all dependencies (including dev for build)
RUN npm ci --include=dev

# Copy source files
COPY tsconfig.json ./
COPY src ./src

# Build TypeScript
RUN npm run build

# Remove dev dependencies after build
RUN npm prune --production

# Start the actor
CMD ["npm", "run", "start"]
