mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-25 02:41:01 +00:00
Compress binary with upx. (#5140)
* Compress binary with upx. * Changing opt-level from z to 3 * Changing lto from thin to fat for release.
This commit is contained in:
parent
cdc1cf3bf7
commit
a4f63294de
2 changed files with 16 additions and 4 deletions
|
@ -26,9 +26,10 @@ workspace = true
|
|||
|
||||
[profile.release]
|
||||
debug = 0
|
||||
lto = "thin"
|
||||
strip = true # Automatically strip symbols from the binary.
|
||||
opt-level = "z" # Optimize for size.
|
||||
lto = "fat"
|
||||
strip = true # Automatically strip symbols from the binary.
|
||||
opt-level = 3 # Optimize for speed, not size.
|
||||
codegen-units = 1 # Reduce parallel code generation.
|
||||
|
||||
# This profile significantly speeds up build time. If debug info is needed you can comment the line
|
||||
# out temporarily, but make sure to leave this in the main branch.
|
||||
|
|
|
@ -38,6 +38,12 @@ RUN --mount=type=cache,target=/lemmy/target set -ex; \
|
|||
cargo clean --release; \
|
||||
cargo build --features "${CARGO_BUILD_FEATURES}" --release; \
|
||||
mv target/"${RUST_RELEASE_MODE}"/lemmy_server ./lemmy_server; \
|
||||
#
|
||||
# Compress the binary with upx
|
||||
wget https://github.com/upx/upx/releases/download/v4.2.4/upx-4.2.4-amd64_linux.tar.xz; \
|
||||
tar -xvf upx-4.2.4-amd64_linux.tar.xz; \
|
||||
cp upx-4.2.4-amd64_linux/upx /usr/bin; \
|
||||
upx --best --lzma lemmy_server; \
|
||||
fi
|
||||
|
||||
# ARM64 builder
|
||||
|
@ -71,9 +77,14 @@ RUN --mount=type=cache,target=./target,uid=10001,gid=10001 set -ex; \
|
|||
cargo clean --release; \
|
||||
cargo build --features "${CARGO_BUILD_FEATURES}" --release; \
|
||||
mv "./target/$CARGO_BUILD_TARGET/$RUST_RELEASE_MODE/lemmy_server" /home/lemmy/lemmy_server; \
|
||||
#
|
||||
# Compress the binary with upx
|
||||
wget https://github.com/upx/upx/releases/download/v4.2.4/upx-4.2.4-arm64_linux.tar.xz; \
|
||||
tar -xvf upx-4.2.4-arm64_linux.tar.xz; \
|
||||
cp upx-4.2.4-arm64_linux/upx /usr/bin; \
|
||||
upx --best --lzma /home/lemmy/lemmy_server; \
|
||||
fi
|
||||
|
||||
|
||||
# amd64 base runner
|
||||
FROM ${AMD_RUNNER_IMAGE} AS runner-linux-amd64
|
||||
|
||||
|
|
Loading…
Reference in a new issue