From 4f5d49ed3a46318ab7f411d38a818a0ee130f221 Mon Sep 17 00:00:00 2001 From: Mr-Leshiy Date: Tue, 28 Nov 2023 11:06:09 +0200 Subject: [PATCH] fix --- docs/src/guides/languages/postgresql.md | 2 +- docs/src/guides/languages/rust.md | 6 +++++- earthly/rust/Earthfile | 25 ++++++++++++++++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/docs/src/guides/languages/postgresql.md b/docs/src/guides/languages/postgresql.md index 793865e29..3c31d5ad1 100644 --- a/docs/src/guides/languages/postgresql.md +++ b/docs/src/guides/languages/postgresql.md @@ -120,7 +120,7 @@ Since we need migration and seed data files, we'll inherit from the `builder` target. The actual image build process is pretty straight-forward and fully defined under the `+BUILD` UDC target. -The only thing it is needed to specify is a few arguments: +The only thing it is needed to specify is a few arguments: * `tag` - the tag of the image, default value `latest`. * `registry` - the registry of the image. diff --git a/docs/src/guides/languages/rust.md b/docs/src/guides/languages/rust.md index 8409f5e38..e74d75a06 100644 --- a/docs/src/guides/languages/rust.md +++ b/docs/src/guides/languages/rust.md @@ -65,8 +65,12 @@ instal all needed tools and dependencies. The fist step of the `builder` target is to prepare a Rust environment via `+rust-base` target. Next step is to copy source code of the project and finally finalize the build which is done with `+SETUP` UDC target. -The `+SETUP` UDC target requires to have a `rust-toolchain.toml` file, +The `+SETUP` UDC target requires `rust-toolchain.toml` file, with the specified `channel` option in it. +This `rust-toolchain.toml` file could be specified +via the `toolchain` argument of the `+SETUP` target like this +with defining the specific location of this file with the specific name. +By default `toolchain` setup to `rust-toolchain.toml`. ### Running checks diff --git a/earthly/rust/Earthfile b/earthly/rust/Earthfile index 7f13fd56b..68ca76686 100644 --- a/earthly/rust/Earthfile +++ b/earthly/rust/Earthfile @@ -6,12 +6,30 @@ VERSION 0.7 # Base Rustup build container. rust-base: + ARG TARGETPLATFORM + ARG TARGETOS + ARG TARGETARCH + ARG TARGETVARIANT + ARG USERPLATFORM + ARG USEROS + ARG USERARCH + ARG USERVARIANT + # This is our base Host toolset, and rustup. # The ACTUAL version of rust that will be used, and available targets # is controlled by a `rust-toolchain.toml` file when the `SETUP` UDC is run. # HOWEVER, It is enforced that the rust version in `rust-toolchain.toml` MUST match this version. FROM rust:1.73-alpine3.18 + RUN echo "TARGETPLATFORM = $TARGETPLATFORM"; \ + echo "TARGETOS = $TARGETOS"; \ + echo "TARGETARCH = $TARGETARCH"; \ + echo "TARGETVARIANT = $TARGETVARIANT"; \ + echo "USERPLATFORM = $USERPLATFORM"; \ + echo "USEROS = $USEROS"; \ + echo "USERARCH = $USERARCH"; \ + echo "USERVARIANT = $USERVARIANT"; + WORKDIR /root # Install necessary packages @@ -63,10 +81,15 @@ rust-base-all-hosts: BUILD --platform=linux/amd64 --platform=linux/arm64 +rust-base # Common Rust setup. +# Parameters: +# * toolchain : The `rust-toolchain` toml file. SETUP: COMMAND - COPY ./rust-toolchain.toml . + ARG toolchain=./rust-toolchain.toml + + # Copy our toolchain dependency. + COPY $toolchain ./rust-toolchain.toml ENV default_rust_channel=$(rg -oP 'channel\s*=\s*"\K[^"]+' rust-toolchain.toml) # Check that `default_rust_channel` and $RUST_VERSION from the rust-base container are exactly the same.