Skip to content

Commit bd20d9e

Browse files
committed
feat: set containerfile rust version via makefile
also set the RUSTUP_TOOLCHAIN env var via the dockerfile, and pass it to deployers
1 parent 0b43e77 commit bd20d9e

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

Containerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#syntax=docker/dockerfile-upstream:1.4.0-rc1
2-
FROM rust:1.65.0-buster as shuttle-build
2+
ARG RUSTUP_TOOLCHAIN
3+
FROM rust:${RUSTUP_TOOLCHAIN}-buster as shuttle-build
34
RUN apt-get update &&\
45
apt-get install -y curl
56
# download protoc binary and unzip it in usr/bin
@@ -26,7 +27,8 @@ COPY --from=cache /build .
2627
ARG folder
2728
RUN cargo build --bin shuttle-${folder}
2829

29-
FROM rust:1.65.0-buster as shuttle-common
30+
ARG RUSTUP_TOOLCHAIN
31+
FROM rust:${RUSTUP_TOOLCHAIN}-buster as shuttle-common
3032
RUN apt-get update &&\
3133
apt-get install -y curl
3234
RUN rustup component add rust-src
@@ -37,4 +39,6 @@ ARG folder
3739
COPY ${folder}/prepare.sh /prepare.sh
3840
RUN /prepare.sh
3941
COPY --from=builder /build/target/debug/shuttle-${folder} /usr/local/bin/service
42+
ARG RUSTUP_TOOLCHAIN
43+
ENV RUSTUP_TOOLCHAIN=${RUSTUP_TOOLCHAIN}
4044
ENTRYPOINT ["/usr/local/bin/service"]

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ endif
2020

2121
BUILDX_FLAGS=$(BUILDX_OP) $(PLATFORM_FLAGS) $(CACHE_FLAGS)
2222

23+
# the rust version used by our containers
24+
RUSTUP_TOOLCHAIN=1.65.0
25+
2326
TAG?=$(shell git describe --tags)
2427
BACKEND_TAG?=$(TAG)
2528
DEPLOYER_TAG?=$(TAG)
@@ -107,6 +110,7 @@ down: docker-compose.rendered.yml
107110
shuttle-%: ${SRC} Cargo.lock
108111
docker buildx build \
109112
--build-arg folder=$(*) \
113+
--build-arg RUSTUP_TOOLCHAIN=$(RUSTUP_TOOLCHAIN) \
110114
--tag $(CONTAINER_REGISTRY)/$(*):$(COMMIT_SHA) \
111115
--tag $(CONTAINER_REGISTRY)/$(*):$(TAG) \
112116
--tag $(CONTAINER_REGISTRY)/$(*):latest \

examples

gateway/src/project.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -481,13 +481,8 @@ impl ProjectCreating {
481481
name: self.container_name(ctx),
482482
};
483483

484-
// Get the version of rustc gateway was compiled with, matching the deployer
485-
// RUSTUP_TOOLCHAIN override with the version from our Containerfile
486-
let rustc_version = rustc_version_runtime::version().to_string();
487-
debug!(
488-
"got installed rustc version for deployer toolchain override: {}",
489-
rustc_version
490-
);
484+
let rustup_toolchain =
485+
std::env::var("RUSTUP_TOOLCHAIN").expect("rustup toolchain should be set");
491486

492487
let container_config = self
493488
.from
@@ -525,7 +520,7 @@ impl ProjectCreating {
525520
"RUST_LOG=debug",
526521
// If we don't set this, users' dependencies with a `rust-toolchain.toml`
527522
// override will compile with incompatible versions of rust.
528-
format!("RUSTUP_TOOLCHAIN={rustc_version}")
523+
format!("RUSTUP_TOOLCHAIN={rustup_toolchain}")
529524
]
530525
})
531526
});

0 commit comments

Comments
 (0)