# Build the portable operator binary.
FROM docker.io/library/rust:1.88-bookworm AS build
WORKDIR /app/src
COPY . .
RUN cargo build --release --bin gravitational_lens --bin gravitational_lens_hash_password

# Runtime sidecar. Mount a target repository at /repo and durable state at /data.
FROM docker.io/library/debian:bookworm-slim
RUN apt-get update \
  && apt-get install -y --no-install-recommends ca-certificates git \
  && rm -rf /var/lib/apt/lists/*
COPY --from=build /app/src/target/release/gravitational_lens /usr/local/bin/gravitational_lens
COPY --from=build /app/src/target/release/gravitational_lens_hash_password /usr/local/bin/gravitational_lens_hash_password
WORKDIR /repo
ENV GRAVITATIONAL_LENS_DATA_ROOT=/data \
    GRAVITATIONAL_LENS_BIND=0.0.0.0:8787 \
    GRAVITATIONAL_LENS_PUBLIC_URL=http://localhost:8787 \
    GRAVITATIONAL_LENS_REPO_DIR=/repo
EXPOSE 8787
ENTRYPOINT ["/usr/local/bin/gravitational_lens"]
