From 276a8c2bd3e4fd1323e66b808675cf14cf6f75c5 Mon Sep 17 00:00:00 2001
From: Nutomic <me@nutomic.com>
Date: Tue, 25 Oct 2022 15:10:07 +0000
Subject: [PATCH] Enable lto, strip symbols via cargo.toml (#2512)

---
 Cargo.toml                 | 6 ++++++
 docker/dev/Dockerfile      | 3 ---
 docker/prod/Dockerfile     | 3 ---
 docker/prod/Dockerfile.arm | 3 ---
 4 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index 18cf4eb39..58fb33257 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,7 +11,13 @@ rust-version = "1.57"
 [lib]
 doctest = false
 
+[profile.release]
+strip = "symbols"
+debug = 0
+lto = "thin"
+
 [profile.dev]
+strip = "symbols"
 debug = 0
 
 [features]
diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile
index 13ff65656..14096dc07 100644
--- a/docker/dev/Dockerfile
+++ b/docker/dev/Dockerfile
@@ -29,9 +29,6 @@ COPY . .
 RUN echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs"
 RUN cargo build --target ${CARGO_BUILD_TARGET}
 
-# reduce binary size
-RUN strip ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server
-
 RUN cp ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server /app/lemmy_server
 
 # The alpine runner
diff --git a/docker/prod/Dockerfile b/docker/prod/Dockerfile
index 68968007c..33a77af88 100644
--- a/docker/prod/Dockerfile
+++ b/docker/prod/Dockerfile
@@ -11,9 +11,6 @@ COPY ./ ./
 RUN echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs"
 RUN cargo build --release
 
-# reduce binary size
-RUN strip ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server
-
 RUN cp ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/lemmy_server /app/lemmy_server
 
 # The alpine runner
diff --git a/docker/prod/Dockerfile.arm b/docker/prod/Dockerfile.arm
index 2076e942d..926fa8a7a 100644
--- a/docker/prod/Dockerfile.arm
+++ b/docker/prod/Dockerfile.arm
@@ -15,9 +15,6 @@ RUN echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/
 
 RUN cargo build --release
 
-# reduce binary size
-RUN strip ./target/release/lemmy_server
-
 RUN cp ./target/release/lemmy_server /app/lemmy_server
 
 # The Debian runner
-- 
GitLab