Skip to content

Commit

Permalink
Minimize binary size by adding -ldflags "-s -w"
Browse files Browse the repository at this point in the history
These build flags reduce binary size by stripping symbol table and debug information.

Signed-off-by: Lucas Rodriguez <lucas.rodriguez9616@gmail.com>
  • Loading branch information
lucasrod16 committed Sep 30, 2024
1 parent 1d53804 commit 7a3e049
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: build-dev
build-dev:
npm --prefix ui run build && CGO_ENABLED=0 go build -o ./bin/api
npm --prefix ui run build && CGO_ENABLED=0 go build -ldflags="-s -w" -o ./bin/api

.PHONY: test-unit
test-unit:
Expand Down
2 changes: 1 addition & 1 deletion scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -euo pipefail
npm --prefix=ui ci
npm --prefix=ui run build

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/api
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ./bin/api

echo "${DOCKER_PASSWORD}" | docker login --username="${DOCKER_USERNAME}" --password-stdin
docker buildx build --no-cache --platform="linux/amd64" --push -t "lucasrod96/oss-contribute:${IMAGE_VERSION}" .
Expand Down

0 comments on commit 7a3e049

Please sign in to comment.