make-deploy/compose.mk

49 lines
1.3 KiB
Makefile
Raw Normal View History

2024-06-05 07:43:19 +00:00
ifdef DOCKER_LOGIN
MANDATORY = $(MANDATORY) DOCKER_USER DOCKER_PASS DOCKER_REGISTRY
endif
2024-06-05 07:29:49 +00:00
ifndef DOCKER_LOGIN
DOCKER_LOGIN = 0
endif
2022-07-05 06:27:53 +00:00
pull-compose:
@- echo "\n### pulling image(s)"
2022-11-09 11:39:22 +00:00
@- $(foreach host,$(DEPLOY_HOSTS), \
2022-11-07 15:57:58 +00:00
echo "$(host)"; \
2022-09-20 11:38:18 +00:00
if test $(DOCKER_LOGIN) -eq 1 ; \
then \
2023-05-04 11:08:35 +00:00
echo "\n#### perfom docker login with user $(DOCKER_USER) on $(DOCKER_REGISTRY)"; \
2022-11-09 11:39:22 +00:00
ssh $(SSH_USER)@$(host) "docker login -u $(DOCKER_USER) -p $(DOCKER_PASS) $(DOCKER_REGISTRY)"; \
2022-09-20 11:38:18 +00:00
fi; \
2024-06-05 07:29:49 +00:00
if test -n "$(DOCKER_IMAGE)" ; \
then \
ssh $(SSH_USER)@$(host) "docker pull $(DOCKER_IMAGE)"; \
fi; \
2022-07-05 06:27:53 +00:00
)
start-compose:
@- echo "\n### starting service(s)"
2022-11-09 11:39:22 +00:00
@- $(foreach host,$(DEPLOY_HOSTS), \
2022-11-07 15:57:58 +00:00
echo "$(host)"; \
2022-11-09 11:39:22 +00:00
ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); docker-compose up -d"; \
sleep $(DEPLOY_START_DELAY); \
2022-07-05 06:27:53 +00:00
)
stop-compose:
@- echo "\n### stopping service(s)"
2022-11-09 11:39:22 +00:00
@- $(foreach host,$(DEPLOY_HOSTS), \
2022-11-07 15:57:58 +00:00
echo "$(host)"; \
2022-11-09 11:39:22 +00:00
ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); docker-compose down"; \
)
2022-07-05 06:27:53 +00:00
logs-compose:
@- echo "\n### logs"
2022-11-09 11:39:22 +00:00
@- ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); docker-compose logs -f $(service)"
2022-07-05 06:27:53 +00:00
restart-compose:
2022-11-09 11:39:22 +00:00
@- $(foreach host,$(DEPLOY_HOSTS), \
2022-11-07 15:57:58 +00:00
echo "$(host)"; \
2022-11-09 11:39:22 +00:00
ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); docker-compose restart"; \
sleep $(DEPLOY_START_DELAY); \
2022-07-05 06:27:53 +00:00
)