build: Dockerfile uses Rust version from `rust-toolchain.toml`
Instead of hardcoding the version of the Rust alpine file, introduce an `ARG` in the `Dockerfile`. In `build/build`, we determine the version by inspecting `rust-toolchain.toml`, and pass this value in. This ensures that the binaries are built using the same toolchain that we develop with.
This commit is contained in:
parent
924b93283c
commit
7dcfe45781
|
|
@ -1,5 +1,8 @@
|
|||
# Builds release binaries for Radicle.
|
||||
FROM rust:1.80-alpine3.20 as builder
|
||||
ARG RUST_VERSION="1.85"
|
||||
ARG ALPINE_VERSION="3.20"
|
||||
|
||||
FROM rust:${RUST_VERSION}-alpine${ALPINE_VERSION} as builder
|
||||
LABEL maintainer="Radicle Team <team@radicle.xyz>"
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ main() {
|
|||
keypath="$(rad path)/keys/radicle.pub"
|
||||
version="$(build/version)"
|
||||
image=radicle-build-$version
|
||||
rust_version="$(build/rust-version)"
|
||||
|
||||
if [ ! -f "$keypath" ]; then
|
||||
echo "fatal: no key found at $keypath" >&2 ; exit 1
|
||||
|
|
@ -40,6 +41,7 @@ main() {
|
|||
|
||||
echo "Building image ($image).."
|
||||
podman --cgroup-manager=cgroupfs build \
|
||||
--build-arg "RUST_VERSION=$rust_version" \
|
||||
--build-arg SOURCE_DATE_EPOCH \
|
||||
--build-arg TZ \
|
||||
--build-arg LC_ALL \
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
if ! version=$(grep -m 1 -oP "channel\s*=\s*\K(.*)" rust-toolchain.toml); then
|
||||
echo "fatal: no rust version found via rust-toolchain.toml" >&2 ; exit 1
|
||||
fi
|
||||
|
||||
echo "$version"
|
||||
Loading…
Reference in New Issue