-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
69 lines (56 loc) · 2.37 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
GOPATH=$(shell go env GOPATH)
IMAGE_REGISTRY=dockerhub
IMAGE_NAMESPACE ?= hansip
IMAGE_NAME ?= $(shell basename `pwd`)
CURRENT_PATH=$(shell pwd)
COMMIT_ID ?= $(shell git rev-parse --short HEAD)
GO111MODULE=on
.PHONY: all test clean build docker
build-static:
-${GOPATH}/bin/go-resource -base "$(CURRENT_PATH)/api/swagger-ui" -path "/docs" -filter "/**/*" -go "$(CURRENT_PATH)/api/StaticApi.go" -package api
go fmt ./...
build: build-static
# export GO111MODULE=on; \
# GO_ENABLED=0 go build -a -o $(IMAGE_NAME).app cmd/main/Main.go
# Use bellow if you're running on linux.
GO_ENABLED=0 go build -a -o $(IMAGE_NAME).app cmd/main/Main.go
lint: build-static
# golint -set_exit_status ./internal/... ./pkg/... ./cmd/...
test: lint
# go install github.com/newm4n/goornogo
export GO111MODULE on; \
go test ./... -cover -vet -all -v -short -covermode=count -coverprofile=coverage.out
# goornogo -i coverage.out -c 30
run: build
export AAA_SERVER_HOST=0.0.0.0; \
export AAA_SERVER_PORT=8088; \
export AAA_SETUP_ADMIN_ENABLE=true; \
export AAA_SERVER_LOG_LEVEL=TRACE; \
export AAA_SERVER_HTTP_CORS_ENABLE=true; \
export AAA_SERVER_HTTP_CORS_ALLOW_ORIGINS=*; \
export AAA_SERVER_HTTP_CORS_ALLOW_CREDENTIAL=true; \
export AAA_SERVER_HTTP_CORS_ALLOW_METHOD=GET,PUT,DELETE,POST,OPTIONS; \
export AAA_SERVER_HTTP_CORS_ALLOW_HEADERS=Accept,Authorization,Content-Type,X-CSRF-TOKEN,Accept-Encoding; \
export AAA_SERVER_HTTP_CORS_EXPOSED_HEADERS=*; \
export AAA_SERVER_HTTP_CORS_IGNOREOPTION=false; \
export AAA_SERVER_HTTP_CORS_OPTIONSTATUS=200; \
export AAA_TOKEN_ISSUER=aaa.hansip.go.id; \
export AAA_MAILER_TYPE=DUMMY; \
export [email protected]; \
./$(IMAGE_NAME).app
rm -f $(IMAGE_NAME).app
docker:
docker build -t $(IMAGE_NAMESPACE)/$(IMAGE_NAME):latest -f ./.docker/Dockerfile .
docker-build-commit: build
docker build -t $(IMAGE_NAMESPACE)/$(IMAGE_NAME):$(COMMIT_ID) -f ./.docker/Dockerfile .
docker-build: build
docker build -t $(IMAGE_NAMESPACE)/$(IMAGE_NAME):$(COMMIT_ID) -f ./.docker/Dockerfile .
docker tag $(IMAGE_NAMESPACE)/$(IMAGE_NAME):$(COMMIT_ID) $(IMAGE_NAMESPACE)/$(IMAGE_NAME):latest
docker-push:
docker push $(IMAGE_NAMESPACE)/$(IMAGE_NAME):$(COMMIT_ID)
docker-stop:
-docker stop $(IMAGE_NAME)
docker-rm: docker-stop
-docker rm $(IMAGE_NAME)
docker-run: docker-rm docker
docker run --name $(IMAGE_NAME) -p 3000:3000 --detach $(IMAGE_NAMESPACE)/$(IMAGE_NAME):latest