FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Paris

# Install PDAL and Python from Ubuntu packages
RUN apt-get update && apt-get install -y --no-install-recommends \
    pdal \
    gdal-bin \
    python3-gdal \
    python3-pip \
    python3-dev \
    build-essential \
    wget \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /data

# Install Python packages via pip
COPY requirements.txt .
RUN pip3 install --no-cache-dir \
    numpy \
    matplotlib \
    whitebox \
    rasterio \
    'laspy[laspy]' \
    scikit-image \
    tqdm

# Copy script
COPY process_lidar.py /usr/local/bin/
RUN chmod +x /usr/local/bin/process_lidar.py

# Create directories with correct permissions
RUN mkdir -p /data/output /data/input && \
    chmod 777 /data /data/output /data/input

VOLUME ["/data"]

CMD ["python3", "/usr/local/bin/process_lidar.py", "/data/input", "-o", "/data/output"]
