46 lines
1.4 KiB
Docker
46 lines
1.4 KiB
Docker
FROM rust:1.94-bookworm AS builder
|
|
|
|
WORKDIR /build
|
|
|
|
RUN apt-get update && apt-get install -y pkg-config libssl-dev && rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy workspace manifests
|
|
COPY Cargo.toml Cargo.lock ./
|
|
|
|
# Copy workspace member manifests
|
|
COPY backend/Cargo.toml backend/Cargo.toml
|
|
COPY types/Cargo.toml types/Cargo.toml
|
|
COPY cli/Cargo.toml cli/Cargo.toml
|
|
|
|
# Stub out every workspace member so Cargo can resolve the graph without full source
|
|
RUN find . -name "Cargo.toml" -not -path "./Cargo.toml" | while read f; do \
|
|
dir=$(dirname "$f"); \
|
|
mkdir -p "$dir/src"; \
|
|
echo 'fn main() {}' > "$dir/src/main.rs"; \
|
|
touch "$dir/src/lib.rs"; \
|
|
done
|
|
|
|
# Build deps only (cache layer)
|
|
RUN cargo build --release -p klog-backend 2>/dev/null || true
|
|
|
|
# Now copy real source
|
|
COPY backend/src backend/src
|
|
COPY types/src types/src
|
|
|
|
# Touch to invalidate cached stubs
|
|
RUN find backend/src types/src -name "*.rs" -exec touch {} +
|
|
|
|
RUN cargo build --release -p klog-backend
|
|
|
|
# ── Runtime image ─────────────────────────────────────────────────────────────
|
|
FROM debian:bookworm-slim
|
|
|
|
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY --from=builder /build/target/release/klog-backend /usr/local/bin/klog-backend
|
|
|
|
ENV PORT=3000
|
|
EXPOSE 3000
|
|
|
|
CMD ["/usr/local/bin/klog-backend"]
|