This repository has been archived by the owner on Jan 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
58 lines (49 loc) · 1.67 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
SHELL := /bin/bash
PROGRAM := sisito-api
VERSION := v0.2.8
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
RUNTIME_GOPATH := $(GOPATH):$(shell pwd)
TEST_SRC := $(wildcard src/*/*_test.go) $(wildcard src/*/test_*.go)
SRC := $(filter-out $(TEST_SRC),$(wildcard src/*/*.go))
TEST_GIN_MODE := release
UBUNTU_IMAGE := docker-go-pkg-build-ubuntu
UBUNTU_CONTAINER_NAME := docker-go-pkg-build-ubuntu-$(shell date +%s)
.PHONY: all
all: $(PROGRAM)
.PHONY: go-get
go-get:
go get github.com/gin-gonic/gin
go get github.com/BurntSushi/toml
go get github.com/go-sql-driver/mysql
go get gopkg.in/gorp.v1
go get github.com/gin-contrib/gzip
go get github.com/stretchr/testify
go get github.com/bouk/monkey
go get github.com/fvbock/endless
$(PROGRAM): $(SRC)
ifeq ($(GOOS),linux)
GOPATH=$(RUNTIME_GOPATH) go build -ldflags "-X sisito.version=$(VERSION)" -a -tags netgo -installsuffix netgo -o $(PROGRAM)
else
GOPATH=$(RUNTIME_GOPATH) go build -ldflags "-X sisito.version=$(VERSION)" -o $(PROGRAM)
endif
.PHONY: test
test: $(TEST_SRC)
GOPATH=$(RUNTIME_GOPATH) GIN_MODE=$(TEST_GIN_MODE) go test -v $(TEST_SRC)
.PHONY: clean
clean: $(TEST_SRC)
rm -f $(PROGRAM)
.PHONY: package
package: clean test $(PROGRAM)
gzip -c $(PROGRAM) > pkg/$(PROGRAM)-$(VERSION)-$(GOOS)-$(GOARCH).gz
rm -f $(PROGRAM)
.PHONY: package/linux
package/linux:
docker run \
--name $(UBUNTU_CONTAINER_NAME) \
-v $(shell pwd):/tmp/src $(UBUNTU_IMAGE) \
make -C /tmp/src go-get package
docker rm $(UBUNTU_CONTAINER_NAME)
.PHONY: docker/build/ubuntu
docker/build/ubuntu: etc/Dockerfile.ubuntu
docker build -f etc/Dockerfile.ubuntu -t $(UBUNTU_IMAGE) .