FROM python:3.11-slim

# 1. Install system dependencies: protobuf-compiler (for gRPC) and 
#    libgdal-dev, libproj-dev, gdal-bin (for GeoAlchemy2/Fiona)
RUN apt-get update \
    && apt-get install -y \
        protobuf-compiler \
        libgdal-dev \
        libproj-dev \
        gdal-bin \
        g++ \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Copy and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy application code
COPY . .

# Corrected COPY path: Assumes 'proto' directory is now in the same directory as the Dockerfile (the build context root)
COPY proto /app/proto

# Compile protobufs
RUN python -m grpc_tools.protoc -I./proto --python_out=. proto/unified_point.proto

CMD ["celery", "-A", "celery_app", "worker", "--loglevel=info"]