| 1 |
# Rust binaries need `libgcc_s.so` but ubuntu's musl toolchain does not have it. |
| 2 |
# Get it from alpine instead. |
| 3 |
FROM alpine:3.16 as libgcc_s_src |
| 4 |
RUN apk add libgcc |
| 5 |
|
| 6 |
# Use something glibc-based for the actual compile because the Rust toolchain |
| 7 |
# we're using is glibc-based in CI. |
| 8 |
FROM ubuntu:24.04 |
| 9 |
RUN apt-get update -y && apt-get install -y cmake musl-tools git ninja-build |
| 10 |
COPY --from=libgcc_s_src /usr/lib/libgcc_s.so.1 /usr/lib/x86_64-linux-musl |
| 11 |
RUN git config --global --add safe.directory '*' |
| 12 |
|
| 13 |
# Note that `-crt-feature` is passed here to specifically disable static linking |
| 14 |
# with musl. We want a `*.so` to pop out so static linking isn't what we want. |
| 15 |
ENV EXTRA_RUSTFLAGS=-Ctarget-feature=-crt-static |
| 16 |
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc |