FROM rust:1.96.0-bookworm AS builder
WORKDIR /app

COPY Cargo.toml Cargo.lock ./
COPY src ./src
COPY cidrs.txt ./cidrs.txt
COPY camfinder-open-rtsp.csv ./camfinder-open-rtsp.csv
COPY rtsp_paths.txt ./rtsp_paths.txt
COPY main_ids.json ./main_ids.json

RUN cargo build --release

FROM debian:bookworm-slim
RUN apt-get update \
    && apt-get install -y --no-install-recommends ca-certificates ffmpeg redis-tools sqlite3 \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app
COPY --from=builder /app/target/release/camfinder /usr/local/bin/camfinder
COPY cidrs.txt /app/cidrs.txt
COPY camfinder-open-rtsp.csv /app/camfinder-open-rtsp.csv
COPY rtsp_paths.txt /app/rtsp_paths.txt
COPY main_ids.json /app/main_ids.json

ENTRYPOINT ["camfinder"]
