-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
869548d
commit 20ce848
Showing
1 changed file
with
2 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,11 @@ | ||
# syntax=docker/dockerfile:1 | ||
FROM --platform=linux/amd64 rust:bookworm AS builder | ||
|
||
ARG LLVM_VERSION=18 | ||
ENV CC=clang-${LLVM_VERSION} CXX=clang-${LLVM_VERSION} CFLAGS="-flto -fuse-ld=lld-${LLVM_VERSION}" CXXFLAGS="-flto -fuse-ld=lld-${LLVM_VERSION}" | ||
|
||
WORKDIR /usr/src/myapp | ||
RUN echo "deb http://apt.llvm.org/bookworm/ llvm-toolchain-bookworm-${LLVM_VERSION} main" > /etc/apt/sources.list.d/llvm.list && \ | ||
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc && apt-get update && \ | ||
apt-get install -y eatmydata && eatmydata apt-get install -y crossbuild-essential-arm64 clang-$LLVM_VERSION lldb-$LLVM_VERSION lld-$LLVM_VERSION clangd-$LLVM_VERSION && \ | ||
rm -rf /var/lib/apt/lists/* | ||
RUN rustup update && rustup toolchain install nightly && rustup target add --toolchain nightly aarch64-unknown-linux-gnu | ||
RUN --mount=type=bind,target=. --mount=type=cache,target=/root/.cargo cargo fetch | ||
ARG TARGETARCH | ||
RUN --mount=type=bind,rw,target=. --mount=type=cache,target=/root/.cargo --mount=type=cache,target=target,id=target-$TARGETARCH \ | ||
if [ "$TARGETARCH" = "arm64" ] ; then \ | ||
CARGO_HOST_LINKER=clang-${LLVM_VERSION} CARGO_HOST_RUSTFLAGS="-Clink-arg=-fuse-ld=lld-${LLVM_VERSION}" \ | ||
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS="-Clinker-plugin-lto -Clinker=clang-${LLVM_VERSION} -Clink-arg=-fuse-ld=lld-${LLVM_VERSION} -Clink-arg=--target=aarch64-unknown-linux-gnu" \ | ||
cargo +nightly -Ztarget-applies-to-host -Zhost-config install --target=aarch64-unknown-linux-gnu --path . ; \ | ||
else \ | ||
RUSTFLAGS="-Clinker-plugin-lto -Clinker=clang-${LLVM_VERSION} -Clink-arg=-fuse-ld=lld-${LLVM_VERSION}" cargo +nightly install --path . ; \ | ||
fi | ||
RUN --mount=type=bind,rw,target=. --mount=type=cache,target=/root/.cargo --mount=type=cache,target=target,id=target cargo install --path . | ||
|
||
FROM debian:bookworm-slim | ||
WORKDIR /hath | ||
COPY --from=builder /usr/local/cargo/bin/hath-rust /usr/local/bin/hath-rust | ||
CMD ["hath-rust"] | ||
ENTRYPOINT ["hath-rust"] |