fix(compilation): use cross for statically linking against musl
This commit is contained in:
parent
3d024db2e9
commit
490dfcf2f2
11 changed files with 115 additions and 169 deletions
21
Dockerfile
21
Dockerfile
|
|
@ -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"]
|
||||
|
|
|
|||
Reference in a new issue