2017-11-14 07:38:23 +08:00
|
|
|
GIT_SHA ?= $(shell git rev-parse HEAD)
|
|
|
|
GIT_TAG ?= $(shell git describe --tags --always)
|
|
|
|
GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
|
2017-11-14 08:13:51 +08:00
|
|
|
LDFLAGS ?= -X main.GIT_SHA=$(GIT_SHA) -X main.GIT_TAG=$(GIT_TAG) -X main.GIT_BRANCH=$(GIT_BRANCH)
|
2017-11-14 16:57:21 +08:00
|
|
|
VERSION ?= $(shell grep 'VERSION =' main.go | cut -d'"' -f2)
|
2017-11-23 16:58:32 +08:00
|
|
|
PORT ?= 2222
|
2017-11-14 07:38:23 +08:00
|
|
|
|
2017-10-31 16:31:36 +08:00
|
|
|
.PHONY: install
|
|
|
|
install:
|
2017-11-14 08:13:51 +08:00
|
|
|
go install -ldflags '$(LDFLAGS)' .
|
|
|
|
|
2017-11-15 18:24:57 +08:00
|
|
|
.PHONY: docker.build
|
|
|
|
docker.build:
|
|
|
|
docker build -t moul/sshportal .
|
|
|
|
|
|
|
|
.PHONY: integration
|
|
|
|
integration:
|
2017-11-23 16:58:32 +08:00
|
|
|
PORT="$(PORT)" bash ./examples/integration/test.sh
|
2017-11-15 18:24:57 +08:00
|
|
|
|
2017-11-14 08:13:51 +08:00
|
|
|
.PHONY: _docker_install
|
|
|
|
_docker_install:
|
|
|
|
CGO_ENABLED=1 go build -ldflags '-extldflags "-static" $(LDFLAGS)' -tags netgo -v -o /go/bin/sshportal
|
2017-10-31 16:31:36 +08:00
|
|
|
|
|
|
|
.PHONY: dev
|
|
|
|
dev:
|
|
|
|
-go get github.com/githubnemo/CompileDaemon
|
2017-11-23 16:58:32 +08:00
|
|
|
CompileDaemon -exclude-dir=.git -exclude=".#*" -color=true -command="./sshportal --demo --debug --port=$(PORT)" .
|
2017-11-13 17:13:17 +08:00
|
|
|
|
|
|
|
.PHONY: test
|
|
|
|
test:
|
|
|
|
go test -i .
|
|
|
|
go test -v .
|
2017-11-14 16:57:21 +08:00
|
|
|
|
|
|
|
.PHONY: backup
|
|
|
|
backup:
|
|
|
|
mkdir -p data/backups
|
|
|
|
cp sshportal.db data/backups/$(shell date +%s)-$(VERSION)-sshportal.sqlite
|