[feat] add pkgs, dockerfile, makefile

This commit is contained in:
Jay
2020-08-16 01:21:27 +08:00
parent f92efa91fc
commit 77cc488d89
16 changed files with 482 additions and 5 deletions
+31
View File
@@ -0,0 +1,31 @@
.PHONY: all
BIN_NAME := api
BUILD_DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
ifneq ($(DRONE_TAG),)
VERSION ?= $(subst v,,$(DRONE_TAG))
else
VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
endif
LDFLAGS ?= -X go-api/pkg/version.Version=$(VERSION) -X go-api/pkg/version.BuildDate=$(BUILD_DATE)
all: clean generate-spec bundle-static build
dev: clean generate-spec bundle-static
build:
go build -o $(BIN_NAME) -ldflags "-s -w $(LDFLAGS)" .
clean:
rm -rf $(BIN_NAME)
go clean
generate-spec:
swagger generate spec -m --compact -o spec.json
build-static:
go-bindata -fs -pkg static -ignore .git -o static/bundle.go public/ schema/ spec.json
test:
go test ./...