Adding lld to docker builds. #810

This commit is contained in:
Dessalines 2020-06-12 16:17:01 -04:00
parent da6de03536
commit 7cb7c1f0f9
2 changed files with 12 additions and 4 deletions

View file

@ -12,6 +12,10 @@ RUN yarn build
FROM ekidd/rust-musl-builder:1.42.0-openssl11 as rust 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 # Cache deps
WORKDIR /app WORKDIR /app
RUN sudo chown -R rust:rust . RUN sudo chown -R rust:rust .
@ -21,13 +25,13 @@ COPY server/Cargo.toml server/Cargo.lock ./
RUN sudo chown -R rust:rust . RUN sudo chown -R rust:rust .
RUN mkdir -p ./src/bin \ RUN mkdir -p ./src/bin \
&& echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs && 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* RUN rm -f ./target/x86_64-unknown-linux-musl/release/deps/lemmy_server*
COPY server/src ./src/ COPY server/src ./src/
COPY server/migrations ./migrations/ COPY server/migrations ./migrations/
# Build for debug # 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 FROM ekidd/rust-musl-builder:1.42.0-openssl11 as docs
WORKDIR /app WORKDIR /app

View file

@ -12,6 +12,10 @@ RUN yarn build
FROM ekidd/rust-musl-builder:1.42.0-openssl11 as rust 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 # Cache deps
WORKDIR /app WORKDIR /app
RUN sudo chown -R rust:rust . RUN sudo chown -R rust:rust .
@ -21,13 +25,13 @@ COPY server/Cargo.toml server/Cargo.lock ./
RUN sudo chown -R rust:rust . RUN sudo chown -R rust:rust .
RUN mkdir -p ./src/bin \ RUN mkdir -p ./src/bin \
&& echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs && 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* RUN rm -f ./target/x86_64-unknown-linux-musl/release/deps/lemmy_server*
COPY server/src ./src/ COPY server/src ./src/
COPY server/migrations ./migrations/ COPY server/migrations ./migrations/
# Build for release # Build for release
RUN cargo build --frozen --release RUN RUSTFLAGS="-Clink-arg=-fuse-ld=lld" cargo build --frozen --release
# reduce binary size # reduce binary size
RUN strip /app/server/target/x86_64-unknown-linux-musl/release/lemmy_server RUN strip /app/server/target/x86_64-unknown-linux-musl/release/lemmy_server