Fix rust version mismatch issues
This commit is contained in:
parent
2075c252f6
commit
e8a971e879
3 changed files with 15 additions and 9 deletions
2
.github/workflows/build-and-deploy.yml
vendored
2
.github/workflows/build-and-deploy.yml
vendored
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
4
rust-engine/rust-toolchain.toml
Normal file
4
rust-engine/rust-toolchain.toml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[toolchain]
|
||||
channel = "1.85.0"
|
||||
# components = ["rustfmt", "clippy"]
|
||||
# targets = ["x86_64-unknown-linux-gnu"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue