# syntax=docker/dockerfile:1

# Use a slim Python image as the base
FROM python:3.10-slim-bookworm

# Set environment variables
ENV PYTHONUNBUFFERED=1

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /code

# Copy only requirements to cache them in docker layer
COPY requirements-cpu.txt /code/requirements-cpu.txt

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements-cpu.txt

# Copy the rest of the application code
COPY pypi_scout /code/pypi_scout/

# Make empty data directory
RUN mkdir -p /code/data

ENV PYTHONPATH=/code

# Use the script as the entrypoint
CMD ["uvicorn", "pypi_scout.api.main:app", "--host", "0.0.0.0", "--port", "8000"]
