Add multiple layers to mitigate dependency issues.
This commit is contained in:
parent
734ecf8293
commit
0eca3ae87c
1 changed files with 17 additions and 1 deletions
|
|
@ -2,15 +2,31 @@
|
|||
|
||||
# --- Stage 1: Builder ---
|
||||
# Use a stable Rust version
|
||||
FROM rust:stable-bookworm AS builder
|
||||
FROM rust:1.82-slim AS builder
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Install build dependencies needed for sqlx
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
pkg-config \
|
||||
libssl-dev \
|
||||
curl \
|
||||
build-essential \
|
||||
ca-certificates \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Allow override of toolchain (stable, nightly, or a pinned version)
|
||||
ARG RUSTUP_TOOLCHAIN=stable
|
||||
|
||||
# Explicit HOME to avoid undefined variable during Docker build
|
||||
ENV HOME=/root
|
||||
|
||||
# Install rustup and ensure the selected toolchain is installed (fixes edition mismatches in CI)
|
||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
|
||||
&& /root/.cargo/bin/rustup toolchain install ${RUSTUP_TOOLCHAIN} \
|
||||
&& /root/.cargo/bin/rustup default ${RUSTUP_TOOLCHAIN}
|
||||
|
||||
ENV PATH="/root/.cargo/bin:${PATH}"
|
||||
|
||||
# Copy manifest files first to leverage Docker layer caching for dependencies
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue