-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
86 lines (71 loc) · 2.55 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
#
# kpu-fe / Makefile
#
#
# VARS
#
# load example variables/constants, override by .env file if exists
# include .env.example
# -include .env
IMAGE_NAME=helldive-helper
PACKAGE_VERSION=$(shell jq -r .version package.json)
APP_ENVIRONMENT?=development
DOCKER_COMPOSE_FILE?=./docker-compose.yml
DOCKER_COMPOSE_FILE_DEV?=./docker-compose.dev.yml
DOCKER_COMPOSE_FILE_E2E?=./docker-compose.test.yml
# define standard colors
# https://gist.github.com/rsperl/d2dfe88a520968fbc1f49db0a29345b9
ifneq (,$(findstring xterm,${TERM}))
BLACK := $(shell tput -Txterm setaf 0)
RED := $(shell tput -Txterm setaf 1)
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
LIGHTPURPLE := $(shell tput -Txterm setaf 4)
PURPLE := $(shell tput -Txterm setaf 5)
BLUE := $(shell tput -Txterm setaf 6)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
else
BLACK := ""
RED := ""
GREEN := ""
YELLOW := ""
LIGHTPURPLE := ""
PURPLE := ""
BLUE := ""
WHITE := ""
RESET := ""
endif
export
#
# TARGETS
#
.PHONY: build
build:
@echo -e "\n${YELLOW} Building project (docker compose build)... ${RESET}\n"
@IMAGE_NAME=${IMAGE_NAME} PACKAGE_VERSION=${PACKAGE_VERSION} REGISTRY_URL=$(registryUrl) APP_NAME=$(appName) docker compose --file $(DOCKER_COMPOSE_FILE) build
.PHONY: push-image
push-image:
@echo -e "\n${YELLOW} Pushing to image registry... ${RESET}\n"
@docker push $(registryUrl)/$(appName)/${IMAGE_NAME}:${PACKAGE_VERSION}
.PHONY: run
run:
@echo -e "\n${YELLOW} Starting project (docker compose up)... ${RESET}\n"
@docker login -u $(login) -p $(password) $(registryUrl)
@IMAGE_NAME=${IMAGE_NAME} PACKAGE_VERSION=${PACKAGE_VERSION} REGISTRY_URL=$(registryUrl) APP_NAME=$(appName) docker compose --file $(DOCKER_COMPOSE_FILE) up $(services) --force-recreate --remove-orphans --detach
.PHONY: dev
dev:
@echo -e "\n${YELLOW} Starting project in local dev mode (docker compose up)... ${RESET}\n"
@docker compose --file $(DOCKER_COMPOSE_FILE_DEV) up --force-recreate --remove-orphans
.PHONY: stop
stop:
@echo -e "\n${YELLOW} Stopping and purging project (docker compose down)... ${RESET}\n"
@docker compose --file $(DOCKER_COMPOSE_FILE) down
.PHONY: logs
logs:
@echo -e "\n${YELLOW} Fetching container's logs (CTRL-C to exit)... ${RESET}\n"
@docker logs ${DOCKER_CONTAINER_NAME} --follow
.PHONY: sh
sh:
@echo -e "\n${YELLOW} Attaching container's shell (CTRL-D to exit)... ${RESET}\n"
@docker exec -it ${DOCKER_CONTAINER_NAME} sh