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