# Multi-stage build for the gitcore Rust crate (staticlib)
# Stage 1: Build the project from source using a Rust toolchain
FROM rust:1.49.0-slim AS builder
WORKDIR /gitcore
# Copy the entire source tree and build
COPY . ./
# Build the static library from source
RUN cargo build --release
# Stage 2: Runtime image
FROM debian:bullseye-slim AS runtime
# Install minimal runtime dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy the built static library from the builder stage
COPY --from=builder /gitcore/target/release/libgitcore.a /usr/local/lib/libgitcore.a
# Ensure library cache path is known
ENV LD_LIBRARY_PATH="/usr/local/lib:${LD_LIBRARY_PATH}"
# Provide a shell for inspection and a stable entrypoint
CMD ["/bin/sh"]