From e1e6249b483b5c59f750f268a3d2eea33c6a988e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Fri, 9 Aug 2024 21:01:26 +0000 Subject: [PATCH] refactor: extract build variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning --- Dockerfile | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6a1d0a2..e8e0fc5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,7 @@ +ARG TARGET_ARCH=x86_64 +ARG TARGET=hermit-${TARGET_ARCH} +ARG PREFIX=/opt/hermit + FROM --platform=$BUILDPLATFORM rust:bookworm AS kernel ADD --link https://github.com/hermit-os/kernel.git#hermit-c /kernel WORKDIR /kernel @@ -9,6 +13,8 @@ RUN cargo xtask build \ --features pci,smp,acpi,newlib,tcp,dhcpv4 FROM buildpack-deps:bookworm AS builder +ARG TARGET +ARG PREFIX RUN set -eux; \ apt-get update; \ @@ -37,10 +43,11 @@ ADD --link https://github.com/hermit-os/newlib.git newlib ADD --link https://github.com/hermit-os/pthread-embedded.git pte ADD --link ./toolchain.sh ./toolchain.sh -RUN ./toolchain.sh x86_64-hermit /opt/hermit +RUN ./toolchain.sh ${TARGET} ${PREFIX} FROM rust:bookworm AS toolchain +ARG PREFIX RUN set -eux; \ apt-get update; \ @@ -51,6 +58,6 @@ RUN set -eux; \ ; \ rm -rf /var/lib/apt/lists/*; -COPY --from=builder /opt/hermit /opt/hermit -ENV PATH=/opt/hermit/bin:$PATH \ - LD_LIBRARY_PATH=/opt/hermit/lib:$LD_LIBRARY_PATH +COPY --from=builder ${PREFIX} ${PREFIX} +ENV PATH=${PREFIX}/bin:$PATH \ + LD_LIBRARY_PATH=${PREFIX}/lib:$LD_LIBRARY_PATH