-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
335 lines (276 loc) · 8.09 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# vim: sw=8
define USAGE
Usage:
make
make binaries
make static # DEPRECATED
make clean
make vendor # DEPRECATED
make vendor-status # DEPRECATED
make vendor-upgrade # DEPRECATED
make vet
make test
make test-t
make errcheck
make images
make gc
make down
make down-state
make up-godoc
make devcerts
make gogen
make meteor # DEPRECATED
make nog-app
make nog-app-2
make deb
make deb-from-product
make docker
make docker-from-product
Make is only used to build Go code in `backend/`. Javascript still uses Npm
scripts.
`make` runs `go install`.
`make clean` removes files that `make` creates. It also removes the `go`
Docker volume, which is necessary after a Docker image change to re-populated
it from the latest image.
`make binaries` builds Linux binaries in `product/bin`. The binaries depend on
glibc. The `netgo` build tag is not supported, because Git2go requires glibc.
See `tools/images/godev/Dockerfile`.
`make static` (DEPRECATED) is an alias for `make binaries`.
`make vendor` is DEPRECATED. Use Go module commands instead, like:
```
godev go list -m all
godev go mod tidy
godev go get ...
godev go get -u=patch # upgrade all to latest patch
godev go get -u # upgrade all to latest minor
```
`make vet`, `make test`, and `make errcheck` run the respective Go tools.
`make test-t` runs the sharness tests in `backend/t/`. See
<https://github.com/chriscool/sharness>. To manually run them:
```
godev bash
cd backend/t
./test-all.sh # All tests.
./t0000-test.sh # Individual tests.
```
`make images` builds Docker dev images explicitly. `make push-dev-images`
pushes the dev images, and `make pull-dev-images` pulls them. To build and
push the dev images to a GitLab container image registry, log in with a
personal access token that has scope `api`, and build and push the dev images,
for example:
```
docker login registry.git.zib.de
DEV_IMAGE_REGISTRY=registry.git.zib.de/nog/nog/ make images push-dev-images
```
`make gc` removes exited containers. `make down` removes Docker objects that
can be re-created. `make down-state` also removes volumes that contain state
that cannot be re-created.
`make up-godoc` starts the godoc server and on Mac opens the project doc in
Chrome.
`make devcert` recreates the SSL certificates used for local testing.
`make gogen` runs `go generate`.
`make meteor` (DEPRECATED) builds the production Meteor app. Use `make
nog-app` instead.
`make nog-app` builds the production Meteor Nog App.
`make nog-app-2` builds the production Meteor Nog App 2.
`make deb` builds the required products and packs them into deb files. `make
deb-from-product` packs the deb files without building the products, assuming
that the products are already up to date.
`make docker` builds products and bundles them into Docker images. `make
docker-from-product` builds the Docker images without building the products,
assuming that the products are already up to date.
See CONTRIBUTING.md for details.
endef
IS_CONTAINER := $(shell test -d /go && echo isContainer)
IS_GIT_FILE := $(shell test -f .git && echo isGitFile)
ifdef IS_CONTAINER
$(error "This Makefile must be used outside the godev container.")
endif
ifdef IS_GIT_FILE
$(error "`.git` is a file. It must be the git dir. See `tools/env.sh`.")
endif
# The build tag encodes information about the Git commit and the build time.
# It is determined outside the container, so that the same Git version is used
# that is also used for managing the worktree.
GIT_COMMIT_TAG := $(shell \
TZ=UTC git show -s \
--date=format-local:%Y%m%dT%H%M%SZ --abbrev=10 --pretty=%cd-g%h \
)
GIT_DIRTY := $(shell \
if [ -n "$$(git status -s)" ]; then echo "-dirty"; fi \
)
BUILD_DATE := $(shell \
date -u +%s \
)
BUILD_TAG := $(GIT_COMMIT_TAG)-b$(BUILD_DATE)$(GIT_DIRTY)
OS := $(shell uname)
DC := docker-compose
DDEV := $(DC) run --rm godev-make
DMAKE := $(DDEV) make -f Makefile.docker BUILD_TAG=$(BUILD_TAG)
.PHONY: all
all:
@echo ' DMAKE all'
$(DMAKE) all
.PHONY: help
export USAGE
help:
@echo "$${USAGE}"
.PHONY: install
install:
@echo ' DMAKE install'
$(DMAKE) install
.PHONY: binaries
binaries:
@echo ' DMAKE binaries'
$(DMAKE) binaries
product/bin/tar-incremental-mtime:
@./tools/bin/make-tar-incremental-mtime
.PHONY: deb
deb: nog-app-2 product/bin/tar-incremental-mtime
@echo ' DMAKE deb'
$(DMAKE) deb
.PHONY: deb-from-product
deb-from-product:
@echo ' DMAKE deb-from-product'
$(DMAKE) deb-from-product
.PHONY: docker
docker: deb
@BUILD_TAG=$(BUILD_TAG) ./tools/bin/make-docker
.PHONY: docker-from-product
docker-from-product: deb-from-product
@BUILD_TAG=$(BUILD_TAG) ./tools/bin/make-docker
.PHONY: static
static:
@echo ' DMAKE static'
@echo 'WARNING: Target `static` is deprecated. Use `binaries` instead.'
$(MAKE) binaries
.PHONY: clean
clean:
@echo ' DMAKE clean'
$(DMAKE) clean
$(MAKE) gc
docker volume rm -f nog_go nog_meteor
.PHONY: vendor
vendor:
@echo ' DEPRECATED vendor'
@echo '`vendor` is no longer used, since Go modules have been enabled.'
.PHONY: vendor-status
vendor-status:
@echo ' DEPRECATED vendor-status'
@echo '`vendor-status` is no longer used, since Go modules have been enabled.'
@echo 'Use Go module commands instead, like:'
@echo
@echo ' godev go list -m all'
@echo
.PHONY: vendor-upgrade
vendor-upgrade:
@echo ' DEPRECATED vendor-upgrade'
@echo '`vendor-upgrade` is no longer used, since Go modules have been enabled.'
@echo 'Use Go module commands instead, like:'
@echo
@echo ' godev go mod tidy'
@echo ' godev go get ...'
@echo
.PHONY: devcerts
devcerts:
@echo ' DMAKE devcerts (force)'
$(DMAKE) -B devcerts
.PHONY: gogen
gogen:
@echo ' DMAKE gogen (force)'
$(DMAKE) -B gogen
.PHONY: vet
vet:
@echo ' DMAKE vet'
$(DMAKE) vet
.PHONY: test
test:
@echo ' DMAKE test'
$(DMAKE) test
.PHONY: test-t
test-t:
@echo ' DMAKE test-t'
$(DMAKE) test-t
.PHONY: errcheck
errcheck:
@echo ' DMAKE errcheck'
$(DMAKE) errcheck
.PHONY: images
images:
@echo ' DOCKER BUILD'
$(DC) build
.PHONY: push-dev-images
push-dev-images:
@echo ' DOCKER PUSH'
$(DC) push dev godev meteordev-make
.PHONY: pull-dev-images
pull-dev-images:
@echo ' DOCKER PULL'
$(DC) pull dev godev meteordev-make
.PHONY: gc
gc:
@echo ' DOCKER RM exited containers'
$(DC) rm -f
.PHONY: down
down:
@echo ' DOCKER COMPOSE down'
$(DC) down
.PHONY: down-state
down-state:
@echo ' DOCKER COMPOSE down stateful'
$(DC) down --volumes
.PHONY: up-godoc
up-godoc:
@echo ' DOCKER COMPOSE up godoc http://localhost:6060'
$(DC) up -d godoc
ifeq ($(OS),Darwin)
@sleep 1
open -b com.google.Chrome http://localhost:6060/pkg/github.com/nogproject/?m=all
else
@echo
@echo open http://localhost:6060/pkg/github.com/nogproject/?m=all
endif
# DEPRECATED: Use `make nog-app` instead of `make meteor`. `make meteor` can
# be removed when control has been migrated to `make nog-app`.
.PHONY: meteor
meteor:
@echo ' METEOR BUILD product/nogappd-meteor.tar.gz'
@mkdir -p product
@$(DC) run --rm meteordev-make bash -c ' \
set -x && \
pushd apps/nog-app/meteor >/dev/null && \
meteor npm install --production && \
meteor build /tmp --architecture os.linux.x86_64 && \
popd >/dev/null && \
mv /tmp/meteor.tar.gz product/nogappd-meteor.tar.gz && \
set +x && \
echo OK product/nogappd-meteor.tar.gz \
'
.PHONY: nog-app
nog-app:
@echo ' METEOR BUILD product/nog-app.tar.gz'
@mkdir -p product
@$(DC) run --rm meteordev-make bash -c ' \
set -x && \
pushd apps/nog-app/meteor >/dev/null && \
meteor npm install --production && \
meteor build /tmp --architecture os.linux.x86_64 && \
popd >/dev/null && \
mv /tmp/meteor.tar.gz product/nog-app.tar.gz && \
set +x && \
echo OK product/nog-app.tar.gz \
'
.PHONY: nog-app-2
nog-app-2:
@echo ' METEOR BUILD product/nog-app-2.tar.gz'
@mkdir -p product
@$(DC) run --rm meteordev-make bash -c ' \
set -x && \
pushd web/apps/nog-app-2 >/dev/null && \
meteor npm install --production && \
meteor build /tmp --architecture os.linux.x86_64 && \
popd >/dev/null && \
mv /tmp/nog-app-2.tar.gz product/nog-app-2.tar.gz && \
set +x && \
echo OK product/nog-app-2.tar.gz \
'