forked from aperezg/goscaffold
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
62 lines (52 loc) · 1.6 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
all: help
##
## ___ ___ __ __ __ _ _
## / _ \ /___\/ _\ ___ __ _ / _|/ _| ___ | | __| |
## / /_\/// //\ \ / __/ _` | |_| |_ / _ \| |/ _` |
## / /_\\/ \_// _\ \ (_| (_| | _| _| (_) | | (_| |
## \____/\___/ \__/\___\__,_|_| |_| \___/|_|\__,_|
##
##
## @author: Adrian Perez <@>
## @description: Makefile for using goscaffold
##
##
MAIN_FILE_PATH:=cmd/goscaffold/main.go
WORK_DIR := "/go/src/github.com/aperezg/goscaffold"
BUILD_DIR := bin
BINARY_NAME := goscaffold
BINARY_LINUX := ${BINARY_NAME}_linux
.PHONY: help
help : Makefile
@sed -n 's/^##//p' $<
##install: Download the require dependencies for the project
.PHONY: install
install:
go get github.com/jteeuwen/go-bindata/...
go get gopkg.in/yaml.v2
##build: Compile on your own architecture
.PHONY: build
build: bindata
go build -o ${BINARY_NAME} ${MAIN_FILE_PATH}
##test: Execute the go test command
.PHONY: test
test:
go test -v ./...
##clean: Execute go clean and remove the binaries
.PHONY: clean
clean:
go clean
##bindata: Transform to binary data the require file for the application
.PHONY: bindata
bindata:
go-bindata -pkg=data -o data/bindata.go doc templates
##cross compilation
##build-linux: Build the project to linux platforms
.PHONY: build-linux
build-linux: bindata
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ${BUILD_DIR} ${MAIN_FILE_PATH}
##docker-build: Build the binary into a docker container
.PHONY: docker-build
docker-build: bindata
docker build -t goscaffold_image .
docker run --rm -it -v "${PWD}":${WORK_DIR} -w ${WORK_DIR} goscaffold_image go build -o $(BUILD_DIR)/${BINARY_LINUX} ${MAIN_FILE_PATH}