Skip to content

Commit

Permalink
Fix API build
Browse files Browse the repository at this point in the history
  • Loading branch information
vladyslav-tk committed Oct 31, 2023
1 parent 105c0c1 commit 02b4601
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,25 @@
FROM rust:1.70 AS builder
ARG mac

# save default values
ARG default_rustflags=${mac:-$RUSTFLAGS}
ARG default_cc=${mac:-$CC_x86_64_unknown_linux_musl}
ARG default_ar=${mac:-$AR_x86_64_unknown_linux_musl}
ARG default_target_rustflags=${mac:-$CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS}
ARG default_target_runner=${mac:-$CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUNNER}
# set values for mac
ENV RUSTFLAGS=${mac:+"-C linker=x86_64-linux-gnu-gcc"}
ENV CC_x86_64_unknown_linux_musl=${mac:+"clang"}
ENV AR_x86_64_unknown_linux_musl=${mac:+"llvm-ar"}
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS=${mac:+"-Clink-self-contained=yes -Clinker=rust-lld"}
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUNNER=${mac:+"qemu-x86_64 -L /usr/x86-64-linux-gnu"}
# set back default values if not mac
ENV RUSTFLAGS="${RUSTFLAGS:-default_rustflags}"
ENV CC_x86_64_unknown_linux_musl="${CC_x86_64_unknown_linux_musl:-default_cc}"
ENV AR_x86_64_unknown_linux_musl="${AR_x86_64_unknown_linux_musl:-default_ar}"
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="${CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS:-default_target_rustflags}"
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUNNER="${CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUNNER:-default_target_runner}"
# additional libs for mac
ENV MAC_INSTALL=${mac:+"build-essential gcc-x86-64-linux-gnu clang llvm"}

RUN apt-get update && apt-get install -y musl-tools musl-dev $MAC_INSTALL
Expand Down

0 comments on commit 02b4601

Please sign in to comment.