fix(compilation): use cross for statically linking against musl

This commit is contained in:
Maxim De Clercq 2021-09-08 15:53:48 +02:00
parent 3d024db2e9
commit 490dfcf2f2
No known key found for this signature in database
GPG key ID: D35643779C52BA70
11 changed files with 115 additions and 169 deletions

View file

@ -1,19 +1,4 @@
FROM rust:1.54
FROM scratch
ENV PREFIX="/usr/src/out/prefix" \
CC="musl-gcc -fPIC -pie -static" \
LD_LIBRARY_PATH="$PREFIX" \
PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" \
PATH="/usr/local/bin:/root/.cargo/bin:$PATH"
RUN apt update && \
apt install -y --no-install-recommends \
musl-dev \
musl-tools \
libpq-dev \
libssl-dev && \
rustup target add x86_64-unknown-linux-musl && \
mkdir "$PREFIX" && \
echo "$PREFIX/lib" >> /etc/ld-musl-x86_64.path
WORKDIR /usr/src/app
COPY target/x86_64-unknown-linux-musl/release/rbd /
RUN ["/rbd"]