-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
128 lines (101 loc) · 3.49 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# TODO: Refactor this to make it more DRY
ROOTDIR := $(shell pwd)
VERSION = $(shell cat VERSION)
BUILD_DATE = $(shell date -u '+%s')
GIT_HASH = $(shell git rev-parse --short HEAD)
VERSION_FLAG=-X main.Version=$(VERSION) -X main.BuildTimestamp=$(BUILD_DATE) -X main.GitHash=$(GIT_HASH)
.PHONY: generated-code
generated-code:
go generate -mod=vendor ./... && gofmt -w pkg && goimports -w pkg
SOURCES=$(shell find . -name "*.go" | grep -v test)
all: all-cli all-docker
all-cli: vrddt-admin vrddt-api vrddt-cli vrddt-web vrddt-worker
all-docker: vrddt-admin-docker vrddt-api-docker vrddt-cli-docker vrddt-web-docker vrddt-worker-docker
#
# ADMIN
#
vrddt-admin: $(SOURCES)
go build -mod=vendor -a -installsuffix cgo -ldflags "-extldflags \"-static\"" -ldflags -v -ldflags "$(VERSION_FLAG)" -o $@ ./cmd/admin
Dockerfile.admin: cmd/Dockerfile.generic
cp $< $@
vrddt-admin-docker: ./Dockerfile.admin
docker build \
-t johnwyles/vrddt-admin:$(VERSION) \
--build-arg VERSION_FLAG="$(VERSION_FLAG)" \
--build-arg VRDDT_COMMAND_PATH="./cmd/admin" \
--build-arg VRDDT_COMMAND="admin" \
-f ./Dockerfile.admin .
rm Dockerfile.admin
vrddt-admin-docker-run:
docker run -mod=vendor johnwyles/vrddt-admin:$(VERSION)
#
# API
#
vrddt-api: $(SOURCES)
go build -mod=vendor -a -installsuffix cgo -ldflags "-extldflags \"-static\"" -ldflags -v -ldflags "$(VERSION_FLAG)" -o $@ ./cmd/api
# Dockerfile.api: cmd/Dockerfile.generic
# cp $< $@
vrddt-api-docker: #./Dockerfile.api
docker build \
-t johnwyles/vrddt-api:$(VERSION) \
--build-arg VERSION_FLAG="$(VERSION_FLAG)" \
--build-arg VRDDT_COMMAND_PATH="./cmd/api" \
--build-arg VRDDT_COMMAND="api" \
-f cmd/Dockerfile.api .
#rm Dockerfile.api
vrddt-api-docker-run:
docker run -mod=vendor johnwyles/vrddt-api:$(VERSION)
#
# CLI
#
vrddt-cli: $(SOURCES)
go build -mod=vendor -a -installsuffix cgo -ldflags "-extldflags \"-static\"" -ldflags -v -ldflags "$(VERSION_FLAG)" -o $@ ./cmd/cli
Dockerfile.cli: cmd/Dockerfile.generic
cp $< $@
vrddt-cli-docker: ./Dockerfile.cli
docker build \
-t johnwyles/vrddt-cli:$(VERSION) \
--build-arg VERSION_FLAG="$(VERSION_FLAG)" \
--build-arg VRDDT_COMMAND_PATH="./cmd/cli" \
--build-arg VRDDT_COMMAND="cli" \
-f ./Dockerfile.cli .
rm Dockerfile.cli
vrddt-cli-docker-run:
docker run -mod=vendor johnwyles/vrddt-cli:$(VERSION)
#
# WEB
#
vrddt-web: $(SOURCES)
go build -mod=vendor -a -installsuffix cgo -ldflags "-extldflags \"-static\"" -ldflags -v -ldflags "$(VERSION_FLAG)" -o $@ ./cmd/web
# Dockerfile.vrddt-web: cmd/Dockerfile
# cp $< $@
vrddt-web-docker: #./Dockerfile.vrddt-web
docker build \
-t johnwyles/vrddt-web:$(VERSION) \
--build-arg VERSION_FLAG="$(VERSION_FLAG)" \
--build-arg VRDDT_COMMAND_PATH="./cmd/web" \
--build-arg VRDDT_COMMAND="web" \
-f cmd/Dockerfile.web .
# rm Dockerfile.vrddt-web
vrddt-web-docker-run:
docker run -mod=vendor johnwyles/vrddt-web:$(VERSION)
#
# WORKER
#
vrddt-worker: $(SOURCES)
go build -mod=vendor -a -installsuffix cgo -ldflags "-extldflags \"-static\"" -ldflags -v -ldflags "$(VERSION_FLAG)" -o $@ ./cmd/worker
# Dockerfile.worker: cmd/Dockerfile
# cp $< $@
vrddt-worker-docker: #./Dockerfile.worker
docker build \
-t johnwyles/vrddt-worker:$(VERSION) \
--build-arg VERSION_FLAG="$(VERSION_FLAG)" \
--build-arg VRDDT_COMMAND_PATH="./cmd/worker" \
--build-arg VRDDT_COMMAND="worker" \
-f cmd/Dockerfile.worker .
# rm Dockerfile.vrddt-worker
vrddt-worker-docker-run:
docker run -mod=vendor johnwyles/vrddt-worker:$(VERSION)
clean:
rm -f Dockerfile.*
rm -rf vendor/