From 1b0b41b824c62c4d434f4dc937d2bd3109917553 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Sat, 22 Jun 2019 23:14:30 +0200 Subject: [PATCH] Add static build target #83 --- Makefile | 3 +++ scripts/build.sh | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 46b49fff5..7184a918a 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,9 @@ build-js: build-go: rm -f $(BINARY_NAME) scripts/build.sh debug $(BINARY_NAME) +build-static: + rm -f $(BINARY_NAME) + scripts/build.sh static $(BINARY_NAME) watch-js: (cd frontend && env NODE_ENV=development npm run watch) test-js: diff --git a/scripts/build.sh b/scripts/build.sh index 3ddd26007..62b9d252c 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -30,9 +30,14 @@ if [[ $1 == "debug" ]]; then go build -ldflags "-X main.version=${PHOTOPRISM_DATE}-${PHOTOPRISM_VERSION}-${PHOTOPRISM_OS}-${PHOTOPRISM_ARCH}-DEBUG" -o $2 cmd/photoprism/photoprism.go du -h $2 echo "Done." +elif [[ $1 == "static" ]]; then + echo "Building static production binary..." + go build -a -v -ldflags "-linkmode external -extldflags \"-static -L /usr/local/lib\" -s -w -X main.version=${PHOTOPRISM_DATE}-${PHOTOPRISM_VERSION}-${PHOTOPRISM_OS}-${PHOTOPRISM_ARCH}" -o $2 cmd/photoprism/photoprism.go + du -h $2 + echo "Done." else - echo "Building production binary..." + echo "Building production binary..." go build -ldflags "-s -w -X main.version=${PHOTOPRISM_DATE}-${PHOTOPRISM_VERSION}-${PHOTOPRISM_OS}-${PHOTOPRISM_ARCH}" -o $2 cmd/photoprism/photoprism.go du -h $2 echo "Done." -fi \ No newline at end of file +fi