Update rust docker to account for regenerating lock file.

This commit is contained in:
Christbru 2025-10-18 18:54:18 -05:00
commit e49a90cf9f

View file

@ -9,14 +9,16 @@ RUN apt-get update && apt-get install -y \
libssl-dev \ libssl-dev \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Copy Cargo files for dependency caching # Copy ONLY Cargo.toml to resolve dependencies
COPY Cargo.toml Cargo.lock ./ COPY Cargo.toml ./
# Create a dummy src/main.rs for dependency build
RUN mkdir src && echo "fn main() {}" > src/main.rs
RUN cargo build --release && rm src/main.rs
# Copy source code and build # KEY CHANGE: Generate lock file and fetch dependencies inside the container
RUN cargo update && cargo fetch
# Now copy the rest of your source code
COPY src ./src COPY src ./src
# Build the project using the pre-fetched dependencies
RUN cargo build --release RUN cargo build --release
# --- Stage 2: Final Image --- # --- Stage 2: Final Image ---