2020-02-08 00:45:22 +08:00
|
|
|
.PHONY: build build-alpine clean test help default docker-build
|
2020-02-07 16:02:18 +08:00
|
|
|
|
|
|
|
BIN_NAME=bashhub-server
|
2020-02-10 09:35:45 +08:00
|
|
|
VERSION=$(shell git tag | sort --version-sort -r | head -1)
|
2020-02-07 16:02:18 +08:00
|
|
|
GIT_COMMIT=$(shell git rev-parse HEAD)
|
|
|
|
GIT_DIRTY=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
|
|
|
|
BUILD_DATE=$(shell date '+%Y-%m-%d-%H:%M:%S')
|
2020-02-17 01:35:28 +08:00
|
|
|
IMAGE_NAME="nicksherron/bashhub-server"
|
2020-02-07 16:02:18 +08:00
|
|
|
|
2020-02-17 01:35:28 +08:00
|
|
|
|
|
|
|
default: help
|
2020-02-07 16:02:18 +08:00
|
|
|
|
|
|
|
help:
|
|
|
|
@echo 'Management commands for bashhub-server:'
|
|
|
|
@echo
|
|
|
|
@echo 'Usage:'
|
2020-02-17 19:44:06 +08:00
|
|
|
@echo ' make build Compile the project'
|
2020-02-17 01:35:28 +08:00
|
|
|
@echo ' make docker-build Build docker image'
|
|
|
|
@echo ' make clean Clean the directory tree'
|
2020-02-17 19:44:06 +08:00
|
|
|
@echo ' make test Run tests on a compiled project'
|
|
|
|
@echo ' make test-postgres Start postgres in ephemeral docker container and run backend tests'
|
|
|
|
@echo ' make test-all Run test and test-postgres'
|
2020-02-07 16:02:18 +08:00
|
|
|
@echo
|
|
|
|
|
|
|
|
build:
|
2020-02-17 01:35:28 +08:00
|
|
|
@echo "building $(BIN_NAME) $(VERSION)"
|
|
|
|
@echo "GOPATH=$(GOPATH)"
|
|
|
|
go build -ldflags "-X github.com/nicksherron/bashhub-server/cmd.Version=$(VERSION) -X github.com/nicksherron/bashhub-server/cmd.GitCommit=$(GIT_COMMIT) -X github.com/nicksherron/bashhub-server/cmd.BuildDate=$(BUILD_DATE)" -o bin/${BIN_NAME}
|
2020-02-08 00:45:22 +08:00
|
|
|
|
|
|
|
docker-build:
|
2020-02-08 01:17:00 +08:00
|
|
|
docker build --no-cache=true --build-arg VERSION=${VERSION} --build-arg BUILD_DATE=${BUILD_DATE} --build-arg GIT_COMMIT=${GIT_COMMIT} -t $(IMAGE_NAME) .
|
2020-02-08 00:45:22 +08:00
|
|
|
|
2020-02-07 16:02:18 +08:00
|
|
|
clean:
|
2020-02-17 01:35:28 +08:00
|
|
|
@test ! -e bin/$(BIN_NAME) || rm bin/$(BIN_NAME)
|
2020-02-07 16:02:18 +08:00
|
|
|
|
|
|
|
test:
|
2020-02-17 01:35:28 +08:00
|
|
|
go test ./...
|
2020-02-14 21:53:40 +08:00
|
|
|
|
|
|
|
test-postgres:
|
2020-02-15 01:43:54 +08:00
|
|
|
scripts/test_postgres.sh
|
2020-02-14 21:53:40 +08:00
|
|
|
|
2020-02-17 01:35:28 +08:00
|
|
|
test-all: test test-postgres
|
|
|
|
|
|
|
|
|
2020-02-14 21:53:40 +08:00
|
|
|
|