diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 2a43ab2..9cda7b5 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -48,8 +48,6 @@ jobs: context: ./rust-engine push: true tags: ghcr.io/${{ steps.repo_name.outputs.name }}/rust-engine:${{ github.sha }} - build-args: | - RUSTUP_TOOLCHAIN=stable cache-from: type=gha cache-to: type=gha,mode=max diff --git a/rust-engine/Dockerfile b/rust-engine/Dockerfile index 087e7fd..5fa6354 100644 --- a/rust-engine/Dockerfile +++ b/rust-engine/Dockerfile @@ -3,7 +3,7 @@ # --- Stage 1: Builder --- # Use a stable Rust version -FROM rust:1.82-slim AS builder +FROM rust:1.85-slim AS builder WORKDIR /usr/src/app # Install build dependencies needed for sqlx @@ -16,18 +16,22 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && rm -rf /var/lib/apt/lists/* -# Allow override of toolchain (stable, nightly, or a pinned version) -ARG RUSTUP_TOOLCHAIN=stable +# Allow optional override of toolchain (e.g., nightly or a pinned version). Leave empty to use image default. +ARG RUSTUP_TOOLCHAIN= # Use rustup and cargo from the official Rust image location ENV PATH="/usr/local/cargo/bin:${PATH}" -# Ensure the selected toolchain is installed and set as default (fixes edition mismatches in CI) -RUN /usr/local/cargo/bin/rustup toolchain install ${RUSTUP_TOOLCHAIN} \ - && /usr/local/cargo/bin/rustup default ${RUSTUP_TOOLCHAIN} +# Optionally install and set the selected toolchain. If not provided, keep the image's default toolchain. +RUN if [ -n "${RUSTUP_TOOLCHAIN}" ]; then \ + /usr/local/cargo/bin/rustup toolchain install "${RUSTUP_TOOLCHAIN}" && \ + /usr/local/cargo/bin/rustup default "${RUSTUP_TOOLCHAIN}"; \ + else \ + /usr/local/cargo/bin/rustup show active-toolchain || true; \ + fi # Copy manifest files first to leverage Docker layer caching for dependencies -COPY Cargo.toml Cargo.lock ./ +COPY Cargo.toml Cargo.lock rust-toolchain.toml ./ # Create a dummy src to allow cargo to download dependencies into the cache layer RUN mkdir -p src && echo "fn main() { println!(\"cargo cache build\"); }" > src/main.rs diff --git a/rust-engine/rust-toolchain.toml b/rust-engine/rust-toolchain.toml new file mode 100644 index 0000000..340fc95 --- /dev/null +++ b/rust-engine/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "1.85.0" +# components = ["rustfmt", "clippy"] +# targets = ["x86_64-unknown-linux-gnu"]