Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Leshiy committed Nov 28, 2023
1 parent 6aba822 commit 4f5d49e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/src/guides/languages/postgresql.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion docs/src/guides/languages/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
25 changes: 24 additions & 1 deletion earthly/rust/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 4f5d49e

Please sign in to comment.