From 0e5159656ae5de34d34b384cab4c8e37de171528 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Wed, 29 Jan 2025 19:13:18 +0400 Subject: ci(fedora41): split install prerequisites and build for Rust packages --- .gitlab/ci/docker/fedora41/Dockerfile | 18 ++++++++++++++---- .gitlab/ci/docker/fedora41/build_rust.sh | 10 ++++++++++ .gitlab/ci/docker/fedora41/install_rust.sh | 10 ---------- 3 files changed, 24 insertions(+), 14 deletions(-) create mode 100755 .gitlab/ci/docker/fedora41/build_rust.sh delete mode 100755 .gitlab/ci/docker/fedora41/install_rust.sh diff --git a/.gitlab/ci/docker/fedora41/Dockerfile b/.gitlab/ci/docker/fedora41/Dockerfile index 25d8e03..67bcbbc 100644 --- a/.gitlab/ci/docker/fedora41/Dockerfile +++ b/.gitlab/ci/docker/fedora41/Dockerfile @@ -15,16 +15,26 @@ RUN --mount=type=bind,source=dnf.conf,target=/etc/dnf/dnf.conf \ dnf install --downloadonly -y $(grep -h '^[^#]\+$' /root/*.lst) -FROM ${BASE_IMAGE} AS rust-build +FROM ${BASE_IMAGE} AS rust-build-env LABEL maintainer="Ben Boeckel " - +# Pre-install prerequisites to build Rust projects. RUN --mount=type=bind,source=dnf.conf,target=/etc/dnf/dnf.conf \ - --mount=type=bind,source=install_rust.sh,target=/root/install_rust.sh \ --mount=type=bind,source=rust_packages.lst,target=/root/rust_packages.lst \ --mount=type=cache,from=dnf-cache,source=/var/cache/libdnf5,target=/var/cache/libdnf5,sharing=private \ --mount=type=tmpfs,target=/var/log \ --mount=type=tmpfs,target=/tmp \ - sh /root/install_rust.sh + dnf install -y $(grep '^[^#]\+$' /root/rust_packages.lst) + + +FROM rust-build-env AS rust-build +LABEL maintainer="Ben Boeckel " +# Build the needed Rust packages. +# https://doc.rust-lang.org/cargo/guide/cargo-home.html?highlight=.cargo#caching-the-cargo-home-in-ci +RUN --mount=type=bind,source=build_rust.sh,target=/root/build_rust.sh \ + --mount=type=cache,target=/root/.cargo/registry/index \ + --mount=type=cache,target=/root/.cargo/registry/cache \ + --mount=type=tmpfs,target=/tmp \ + sh /root/build_rust.sh FROM ${BASE_IMAGE} AS rvm-build-env diff --git a/.gitlab/ci/docker/fedora41/build_rust.sh b/.gitlab/ci/docker/fedora41/build_rust.sh new file mode 100755 index 0000000..f20949b --- /dev/null +++ b/.gitlab/ci/docker/fedora41/build_rust.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +set -e + +typos_version=1.29.4 +cargo install --root /usr/local --version "$typos_version" typos-cli + +strip /usr/local/bin/typos + +tar -C /usr/local -cf /root/rust.tar bin/typos diff --git a/.gitlab/ci/docker/fedora41/install_rust.sh b/.gitlab/ci/docker/fedora41/install_rust.sh deleted file mode 100755 index d6d6e43..0000000 --- a/.gitlab/ci/docker/fedora41/install_rust.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -set -e - -dnf install -y $(grep '^[^#]\+$' /root/rust_packages.lst) - -typos_version=1.29.4 -cargo install --root /usr/local --version "$typos_version" typos-cli - -tar -C /usr/local -cf /root/rust.tar bin/typos -- cgit v0.12