From 7cb7c1f0f9a77c3019200edffa5381f8a4d76e55 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 12 Jun 2020 16:17:01 -0400 Subject: [PATCH] Adding lld to docker builds. #810 --- docker/dev/Dockerfile | 8 ++++++-- docker/prod/Dockerfile | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile index fbec25367..3ebfa0972 100644 --- a/docker/dev/Dockerfile +++ b/docker/dev/Dockerfile @@ -12,6 +12,10 @@ RUN yarn build FROM ekidd/rust-musl-builder:1.42.0-openssl11 as rust +# Install lld +RUN sudo apt-get update -y +RUN sudo apt-get install -y lld + # Cache deps WORKDIR /app RUN sudo chown -R rust:rust . @@ -21,13 +25,13 @@ COPY server/Cargo.toml server/Cargo.lock ./ RUN sudo chown -R rust:rust . RUN mkdir -p ./src/bin \ && echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs -RUN cargo build +RUN RUSTFLAGS="-Clink-arg=-fuse-ld=lld" cargo build RUN rm -f ./target/x86_64-unknown-linux-musl/release/deps/lemmy_server* COPY server/src ./src/ COPY server/migrations ./migrations/ # Build for debug -RUN cargo build +RUN RUSTFLAGS="-Clink-arg=-fuse-ld=lld" cargo build FROM ekidd/rust-musl-builder:1.42.0-openssl11 as docs WORKDIR /app diff --git a/docker/prod/Dockerfile b/docker/prod/Dockerfile index b9eec4565..bc17a186a 100644 --- a/docker/prod/Dockerfile +++ b/docker/prod/Dockerfile @@ -12,6 +12,10 @@ RUN yarn build FROM ekidd/rust-musl-builder:1.42.0-openssl11 as rust +# Install lld +RUN sudo apt-get update -y +RUN sudo apt-get install -y lld + # Cache deps WORKDIR /app RUN sudo chown -R rust:rust . @@ -21,13 +25,13 @@ COPY server/Cargo.toml server/Cargo.lock ./ RUN sudo chown -R rust:rust . RUN mkdir -p ./src/bin \ && echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs -RUN cargo build --release +RUN RUSTFLAGS="-Clink-arg=-fuse-ld=lld" cargo build --release RUN rm -f ./target/x86_64-unknown-linux-musl/release/deps/lemmy_server* COPY server/src ./src/ COPY server/migrations ./migrations/ # Build for release -RUN cargo build --frozen --release +RUN RUSTFLAGS="-Clink-arg=-fuse-ld=lld" cargo build --frozen --release # reduce binary size RUN strip /app/server/target/x86_64-unknown-linux-musl/release/lemmy_server