-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
43 lines (31 loc) · 884 Bytes
/
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
.PHONY: deploy
COMPOSE=docker compose
TEST_PROFILE=test
PROD_PROFILE=prod
TEST_ENV_FILE=.env.local
PROD_ENV_FILE=.env.production.local
ENV_FILE=$(TEST_ENV_FILE)
ifeq ($(profile),$(PROD_PROFILE))
ENV_FILE=$(PROD_ENV_FILE)
endif
define gen_compose_flags
--env-file $(ENV_FILE) --profile $(1)
endef
define gen_compose_command
PROFILE=$(strip $(1)) $(COMPOSE) $(call gen_compose_flags,$(1))
endef
COMPOSE_DEPLOY_COMMAND=$(call gen_compose_command,$(profile))
UP_FLAGS_DEPLOY=-d --force-recreate
all:
@echo "Usage: make BUILD_TARGET"
@echo ""
@echo "BUILD_TARGET:"
@echo "\tdeploy profile=\t-\tdeploy with profile prod or test"
deploy: check_deploy_environment
$(COMPOSE_DEPLOY_COMMAND) pull
$(COMPOSE_DEPLOY_COMMAND) up $(UP_FLAGS_DEPLOY)
check_deploy_environment: check_profile_exists
check_profile_exists:
ifeq ($(profile),)
(error profile argument not set)
endif