# -----------------------------------------------------------------------
# TensorFlow CNN Starter — Dockerfile
# Builds a CPU-only image suitable for serving and training.
# For GPU: change the base image to tensorflow/tensorflow:2.15.0-gpu
# -----------------------------------------------------------------------
FROM tensorflow/tensorflow:2.15.0

# Metadata
LABEL maintainer="DemIA Living Lab - USAL / BISITE"
LABEL description="TensorFlow CNN image-classification starter"

# Install system packages needed by Pillow
RUN apt-get update && apt-get install -y --no-install-recommends \
        libgl1 \
        libglib2.0-0 \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Copy dependency manifest first (layer-cache friendly)
COPY requirements.txt ./

# Install Python dependencies (tensorflow is already in base image,
# but re-pinning ensures version consistency)
RUN pip install --no-cache-dir -r requirements.txt

# Copy project source
COPY . .

# Create output directory
RUN mkdir -p outputs

# Expose the FastAPI port
EXPOSE 8000

# Default command: start the API server.
# Override to run training:
#   docker run ... python scripts/run.py train
CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8000"]
