Repository navigation
Expand file tree
/
Copy pathDockerfile.build
More file actions
53 lines (42 loc) · 2.11 KB
/
Copy pathDockerfile.build
File metadata and controls
53 lines (42 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Multi-stage Dockerfile for building vtcode with sufficient memory and resources.
# This is a contributor build image, not a shipped runtime: releases ship
# prebuilt binaries (see scripts/release.sh), not containers. Base images are
# pinned by digest for reproducible builds; refresh with `docker buildx
# imagetools inspect <tag>` when the toolchain pin moves (checked by
# scripts/check_compatibility.sh, which reads the tag, not the digest).
FROM rust:1.100.0-slim-bookworm@sha256:7c7d4eb4d05b7781187a327809466cfddf29753f6defdc3d19a0e291951b7a37 AS builder
# Install required build tools and apply available distro security fixes.
RUN apt-get update && apt-get upgrade -y \
&& apt-get install -y --no-install-recommends build-essential git libssl-dev pkg-config \
&& 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
ENV RUSTC_WRAPPER=
ENV SCCACHE_DIR=
ENV SCCACHE_CACHE_SIZE=
# Use the same thin-LTO profile as Linux release CI to keep link memory bounded.
RUN cargo build --locked --profile release-fast
# Verify the binary was created
RUN test -f /build/target/release-fast/vtcode
# Optional: Create a minimal runtime image
FROM debian:trixie-slim@sha256:a72b4433de1cf7d6bae0c4cee74d0547f58601a643b3375f070c51600d63b6b2 AS runtime
# Install runtime dependencies
RUN apt-get update && apt-get upgrade -y \
&& apt-get install -y --no-install-recommends ca-certificates libssl3t64 \
&& rm -rf /var/lib/apt/lists/*
# Copy the built binary from builder stage
COPY --from=builder --chmod=755 /build/target/release-fast/vtcode /usr/local/bin/vtcode
# Run as an unprivileged user: nothing in this image needs root. The home
# directory is created (not /nonexistent) because interactive vtcode sessions
# write config/state under $HOME.
RUN groupadd -r vtcode && useradd -r -m -g vtcode -d /home/vtcode -s /usr/sbin/nologin vtcode
USER vtcode
# Set the entrypoint
ENTRYPOINT ["/usr/local/bin/vtcode"]
CMD ["--help"]