# Multi-stage Dockerfile for building vtcode with sufficient memory and resources
FROM rust:1.90.0-bookworm as builder
# Install required system dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /build
# Copy the entire project
COPY . .
# Configure cargo to use less memory during compilation
# by reducing parallel jobs and disabling incremental compilation
ENV CARGO_BUILD_JOBS=2
ENV CARGO_INCREMENTAL=0
# Build the project with release profile (more memory efficient than dev with LTO)
# Use --release to get optimized binary without the aggressive dev LTO settings
RUN cargo build --release
# Verify the binary was created
RUN test -f /build/target/release/vtcode
# Optional: Create a minimal runtime image
FROM debian:bookworm-slim as runtime
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
&& rm -rf /var/lib/apt/lists/*
# Copy the built binary from builder stage
COPY --from=builder /build/target/release/vtcode /usr/local/bin/vtcode
# Set the entrypoint
ENTRYPOINT ["/usr/local/bin/vtcode"]
CMD ["--help"]