-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
67 lines (56 loc) · 1.26 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
REGISTRY = servicenowdocker
IMAGE = azimuth
TAG = latest
DEVICE = auto
STAGE = production
ENV_FILE = .app_env
export DOCKER_BUILDKIT ?= 1
ifeq ($(DEVICE),auto)
GPU_AVAILABLE=$(shell nvidia-smi 1>/dev/null 2>/dev/null && echo "success")
ifeq ($(GPU_AVAILABLE),success)
export DEVICE=gpu
else
export DEVICE=cpu
endif
endif
ifeq ($(STAGE),production)
TAG_EXT=
else
TAG_EXT=_test
endif
ifeq ($(DEVICE),gpu)
COMPOSE_EXT=-f docker-compose-gpu.yml
else
COMPOSE_EXT=
endif
include makefiles/Makefile.security
include makefiles/Makefile.test
include makefiles/Makefile.local
include makefiles/Makefile.demo
.PHONY: build
build: build_be build_fe
.PHONY: build_be
build_be:
docker build \
--build-arg DEVICE=$(DEVICE) \
--build-arg STAGE=$(STAGE) \
-t $(REGISTRY)/$(IMAGE):$(TAG)_$(DEVICE)$(TAG_EXT) \
.
.PHONY: build_fe
build_fe:
docker build \
--target $(STAGE) \
-t $(REGISTRY)/$(IMAGE)-app:$(TAG)$(TAG_EXT) \
webapp/.
.PHONY: compose
compose: build launch
.PHONY: launch
launch:
docker compose -f docker-compose.yml $(COMPOSE_EXT) --env-file $(ENV_FILE) up
.PHONY: push
push:
docker push $(REGISTRY)/$(IMAGE):$(TAG)_$(DEVICE)$(TAG_EXT)
docker push $(REGISTRY)/$(IMAGE)-app:$(TAG)$(TAG_EXT)
.PHONY: docs_serve
docs_serve:
cd docs && mkdocs serve