From 1ccf256b99fcc49e9e077a29b305de50e59eaf8c Mon Sep 17 00:00:00 2001 From: naskya Date: Sun, 7 Jan 2024 19:03:20 +0900 Subject: [PATCH] docker: use mold linker for Rust compilation --- Dockerfile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4b6b3207..639202fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,10 +3,17 @@ FROM docker.io/node:21-slim as build WORKDIR /firefish # Install compilation dependencies -RUN apt-get update && DEBIAN_FRONTEND='noninteractive' apt-get install -y --no-install-recommends curl build-essential ca-certificates +RUN apt-get update && DEBIAN_FRONTEND='noninteractive' apt-get install -y --no-install-recommends curl build-essential ca-certificates clang RUN curl --proto '=https' --tlsv1.2 --silent --show-error --fail https://sh.rustup.rs | sh -s -- -y ENV PATH="/root/.cargo/bin:${PATH}" +RUN echo 'deb https://deb.debian.org/debian testing main' | tee /etc/apt/sources.list +RUN apt-get update && DEBIAN_FRONTEND='noninteractive' apt-get --target-release testing install -y --no-install-recommends mold +RUN < /root/.cargo/config + echo "[target.aarch64-unknown-linux-gnu]\nlinker = '$(which clang)'\nrustflags = ['-C', 'link-arg=--ld-path=$(which mold)']" >> /root/.cargo/config +EOC + # Copy only the cargo dependency-related files first, to cache efficiently COPY packages/backend/native-utils/Cargo.toml packages/backend/native-utils/Cargo.toml COPY packages/backend/native-utils/Cargo.lock packages/backend/native-utils/Cargo.lock