FROM rust:1.88-bookworm AS builder

WORKDIR /src

RUN apt-get update && apt-get install -y --no-install-recommends \
    pkg-config \
    libgstreamer1.0-dev \
    libgstreamer-plugins-base1.0-dev \
    libglib2.0-dev \
    libgtk-4-dev \
    libasound2-dev \
  && rm -rf /var/lib/apt/lists/*

COPY . .

RUN cargo build --release --manifest-path client/Cargo.toml

FROM debian:bookworm-slim

LABEL org.opencontainers.image.source="https://scm.bstein.dev/bstein/lesavka"

RUN apt-get update && apt-get install -y --no-install-recommends \
    libgtk-4-1 \
    libgstreamer1.0-0 \
    libgstreamer-plugins-base1.0-0 \
    gstreamer1.0-plugins-base \
    gstreamer1.0-plugins-good \
    gstreamer1.0-plugins-bad \
    gstreamer1.0-plugins-ugly \
    gstreamer1.0-libav \
    libglib2.0-0 \
    libasound2 \
    libx11-6 \
    libxext6 \
    libxfixes3 \
    libxi6 \
    libxrandr2 \
    libxrender1 \
    libxkbcommon0 \
    libwayland-client0 \
    libwayland-cursor0 \
    libwayland-egl1 \
    libegl1 \
    libgl1 \
  && rm -rf /var/lib/apt/lists/*

COPY --from=builder /src/client/target/release/lesavka-client /usr/local/bin/lesavka-client

ENTRYPOINT ["lesavka-client"]
