# pfaedle: rechnet aus OpenStreetMap die echten Streckenverläufe
FROM debian:trixie AS pfaedle
RUN apt-get update && apt-get install -y --no-install-recommends \
      ca-certificates git cmake g++ make libzip-dev zlib1g-dev libbz2-dev \
 && git clone --depth 1 --recurse-submodules --shallow-submodules https://github.com/ad-freiburg/pfaedle /src \
 && cmake -S /src -B /build -DCMAKE_BUILD_TYPE=Release \
 && make -C /build -j"$(nproc)" pfaedle \
 && make -C /build install

# pmtiles: schneidet die Kartenkacheln für die Region aus
FROM golang:1.25-trixie AS pmtiles
RUN go install github.com/protomaps/go-pmtiles@v1.31.2

FROM python:3.13-slim-trixie
RUN apt-get update && apt-get install -y --no-install-recommends libzip5 zlib1g libbz2-1.0 libgomp1 \
 && rm -rf /var/lib/apt/lists/*
COPY --from=pfaedle /usr/local/bin/pfaedle /usr/local/bin/
COPY --from=pfaedle /usr/local/etc/pfaedle /usr/local/etc/pfaedle
COPY --from=pmtiles /go/bin/go-pmtiles /usr/local/bin/pmtiles
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY trainpulse trainpulse
COPY web web
COPY tests tests
ENV TRAINPULSE_DATA=/data PYTHONUNBUFFERED=1
EXPOSE 8080
CMD ["uvicorn", "trainpulse.server:app", "--host", "0.0.0.0", "--port", "8080", "--proxy-headers"]
