# syntax=docker/dockerfile:1.7
FROM nvidia/cuda:12.8.1-cudnn-runtime-ubuntu22.04

ENV DEBIAN_FRONTEND=noninteractive \
    PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PYTHONPATH=/app:/app/NN_server

WORKDIR /app

RUN apt-get update && apt-get install -y --no-install-recommends \
    python3 \
    python3-pip \
    python3-venv \
    git \
    libglib2.0-0 \
    libgl1 \
    libsm6 \
    libxext6 \
    libxrender-dev \
    && rm -rf /var/lib/apt/lists/*

COPY deploy/requirements/nn_gpu_pinned.txt /tmp/nn_gpu_pinned.txt
COPY deploy/requirements/nn_common.txt /tmp/nn_common.txt

RUN --mount=type=cache,target=/root/.cache/pip \
    python3 -m pip install --upgrade pip && \
    python3 -m pip install -r /tmp/nn_gpu_pinned.txt && \
    python3 -m pip install -r /tmp/nn_common.txt && \
    python3 -m pip install watchdog

COPY . /app

RUN --mount=type=cache,target=/root/.cache/pip \
    python3 -m pip install -e /app/torchsig

WORKDIR /app/NN_server
EXPOSE 8080
CMD ["python3", "server.py"]
