FROM python:3.11-slim

WORKDIR /app

# System deps (curl for healthchecks)
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*

# Install poetry
RUN pip install --no-cache-dir poetry

# Copy workflows package first (dependency)
COPY workflows ./workflows

# Copy platform_worker poetry files for caching
COPY platform_worker/pyproject.toml platform_worker/poetry.lock* ./platform_worker/

# Install dependencies only (without the project itself)
WORKDIR /app/platform_worker
RUN poetry config virtualenvs.create false && \
    poetry install --no-interaction --no-ansi --only main --no-root

# Copy platform_worker code
COPY platform_worker/platform_worker ./platform_worker

# Install the project itself
RUN poetry install --no-interaction --no-ansi --only main

# Run worker
CMD ["python", "-m", "platform_worker.main"]
