FROM rust:1-bookworm AS builder

WORKDIR /app

COPY Cargo.toml Cargo.lock ./
COPY src ./src
COPY web ./web

RUN cargo build --release --locked

FROM debian:bookworm-slim

RUN apt-get update \
    && apt-get install -y --no-install-recommends ca-certificates ffmpeg \
    && useradd --system --uid 10001 --create-home lanplay \
    && rm -rf /var/lib/apt/lists/*

COPY --from=builder /app/target/release/lan-play /usr/local/bin/lan-play

USER lanplay
WORKDIR /home/lanplay

EXPOSE 8080
ENTRYPOINT ["lan-play"]
CMD ["/media", "--bind", "0.0.0.0:8080"]
