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
|
context: ./rust-engine
|
||||||
push: true
|
push: true
|
||||||
tags: ghcr.io/${{ steps.repo_name.outputs.name }}/rust-engine:${{ github.sha }}
|
tags: ghcr.io/${{ steps.repo_name.outputs.name }}/rust-engine:${{ github.sha }}
|
||||||
build-args: |
|
|
||||||
RUSTUP_TOOLCHAIN=stable
|
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
# --- Stage 1: Builder ---
|
# --- Stage 1: Builder ---
|
||||||
# Use a stable Rust version
|
# Use a stable Rust version
|
||||||
FROM rust:1.82-slim AS builder
|
FROM rust:1.85-slim AS builder
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
# Install build dependencies needed for sqlx
|
# 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/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
|
||||||
# Allow override of toolchain (stable, nightly, or a pinned version)
|
# Allow optional override of toolchain (e.g., nightly or a pinned version). Leave empty to use image default.
|
||||||
ARG RUSTUP_TOOLCHAIN=stable
|
ARG RUSTUP_TOOLCHAIN=
|
||||||
|
|
||||||
# Use rustup and cargo from the official Rust image location
|
# Use rustup and cargo from the official Rust image location
|
||||||
ENV PATH="/usr/local/cargo/bin:${PATH}"
|
ENV PATH="/usr/local/cargo/bin:${PATH}"
|
||||||
|
|
||||||
# Ensure the selected toolchain is installed and set as default (fixes edition mismatches in CI)
|
# Optionally install and set the selected toolchain. If not provided, keep the image's default toolchain.
|
||||||
RUN /usr/local/cargo/bin/rustup toolchain install ${RUSTUP_TOOLCHAIN} \
|
RUN if [ -n "${RUSTUP_TOOLCHAIN}" ]; then \
|
||||||
&& /usr/local/cargo/bin/rustup default ${RUSTUP_TOOLCHAIN}
|
/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 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
|
# 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
|
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