diff --git a/Makefile b/Makefile index ec89cc0d6..c2ce2dbbd 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ DOCKER_TAG=`date -u +%Y%m%d` all: download dep js build install: install-bin install-assets install-config install-bin: - cp $(BINARY_NAME) /usr/local/bin/$(BINARY_NAME) + scripts/build.sh install /usr/local/bin/$(BINARY_NAME) install-assets: mkdir -p /srv/photoprism mkdir -p /srv/photoprism/photos @@ -25,11 +25,12 @@ install-assets: cp -r assets/public /srv/photoprism cp -r assets/templates /srv/photoprism cp -r assets/tensorflow /srv/photoprism + find /srv/photoprism -name '.*' -type f -delete install-config: mkdir -p /etc/photoprism test -e /etc/photoprism/photoprism.yml || cp -n configs/photoprism.yml /etc/photoprism/photoprism.yml build: - scripts/build.sh + scripts/build.sh debug $(BINARY_NAME) js: (cd frontend && yarn install --frozen-lockfile --prod) (cd frontend && env NODE_ENV=production npm run build) diff --git a/scripts/build.sh b/scripts/build.sh index 503a5e2a6..dda58ff66 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -3,12 +3,17 @@ VERSION=`date -u +0.%Y%m%d.%H%M%S` BRANCH=`git rev-parse --abbrev-ref HEAD` -if [ ${BRANCH} == "master" ]; then - echo "Building production binary..." - go build -ldflags "-s -w -X main.version=${VERSION}" cmd/photoprism/photoprism.go +if [ -z "$1" ] || [ -z "$2" ]; then + echo "Please provide build mode and output file name" 1>&2 + exit 1 +fi + +if [ $1 == "debug" ]; then + echo "Building development binary..." + go build -ldflags "-X main.version=${VERSION}-${BRANCH}" -o $2 cmd/photoprism/photoprism.go echo "Done." else - echo "Building development binary..." - go build -ldflags "-X main.version=${VERSION}-${BRANCH}" cmd/photoprism/photoprism.go + echo "Building production binary..." + go build -ldflags "-s -w -X main.version=${VERSION}" -o $2 cmd/photoprism/photoprism.go echo "Done." fi \ No newline at end of file