11.DEFAULT_GOAL := help
22
3-
4-
53# Internal VARIABLES ------------------------------------------------
64# STACK_NAME defaults to name of the current directory. Should not to be changed if you follow GitOps operating procedures.
75STACK_NAME = $(notdir $(shell pwd) )
86TEMP_COMPOSE =.stack.${STACK_NAME}.yaml
97REPO_BASE_DIR := $(shell git rev-parse --show-toplevel)
108
9+ DOCKER_STACK_DEPLOY_COMMON_DEPENDENCIES = .api_env.secret \
10+ prune-docker-stack-configs \
11+ prune-docker-stack-secrets
12+
1113# TARGETS --------------------------------------------------
1214include ${REPO_BASE_DIR}/scripts/common.Makefile
1315
1416.PHONY : up-aws # # Deploys stack on aws
15- up-aws : .init .env ${TEMP_COMPOSE}-aws .api_env.secret
17+ up-aws : .init .env ${TEMP_COMPOSE}-aws ${DOCKER_STACK_DEPLOY_COMMON_DEPENDENCIES}
1618 @docker stack deploy --with-registry-auth --prune --compose-file ${TEMP_COMPOSE} -aws ${STACK_NAME}
1719
1820.PHONY : up-master # # Deploys stack on master
19- up-master : .init .env ${TEMP_COMPOSE}-master .api_env.secret
21+ up-master : .init .env ${TEMP_COMPOSE}-master ${DOCKER_STACK_DEPLOY_COMMON_DEPENDENCIES}
2022 @docker stack deploy --with-registry-auth --prune --compose-file ${TEMP_COMPOSE} -master ${STACK_NAME}
2123
2224.PHONY : up-local # # Deploys stack on local
23- up-local : .init .env ${TEMP_COMPOSE}-local .api_env.secret
25+ up-local : .init .env ${TEMP_COMPOSE}-local ${DOCKER_STACK_DEPLOY_COMMON_DEPENDENCIES}
2426 @docker stack deploy --with-registry-auth --prune --compose-file ${TEMP_COMPOSE} -local ${STACK_NAME}
2527
2628# Helpers -------------------------------------------------
2729
30+ docker-compose.yml : .env .api_env.secret
31+ @$(call jinja, docker-compose.yml.j2, .env, docker-compose.yml.unlinted) && \
32+ $(_yq ) docker-compose.yml.unlinted > docker-compose.yml; \
33+ rm docker-compose.yml.unlinted > /dev/null 2>&1 ;
34+
2835.PHONY : ${TEMP_COMPOSE}-aws
2936${TEMP_COMPOSE}-aws : docker-compose.yml docker-compose.aws.yml
3037 @${REPO_BASE_DIR} /scripts/docker-stack-config.bash -e .env $< docker-compose.aws.yml > $@
@@ -37,6 +44,5 @@ ${TEMP_COMPOSE}-master: docker-compose.yml docker-compose.master.yml
3744${TEMP_COMPOSE}-local : docker-compose.yml docker-compose.local.yml
3845 @${REPO_BASE_DIR} /scripts/docker-stack-config.bash -e .env $< docker-compose.local.yml > $@
3946
40-
4147.api_env.secret : .env template.api_env # # resolves '.api_env.secret' using '.env'
4248 @set -o allexport; source $< ; set +o allexport; envsubst < $(word 2,$^ ) > $@
0 commit comments