make-deploy/compose-file.mk

47 lines
1.6 KiB
Makefile
Raw Permalink Normal View History

2024-06-05 07:29:49 +00:00
MANDATORY-compose-file = DEPLOY_HOSTS DEPLOY_TYPE SSH_USER DEPLOY_COMPOSE_FILE DEPLOY_COMPOSE_PROJECT
ifndef DOCKER_LOGIN
DOCKER_LOGIN = 0
endif
2023-04-27 07:01:39 +00:00
pull-compose-file:
@- echo "\n### pulling image(s)"
@- $(foreach host,$(DEPLOY_HOSTS), \
echo "$(host)"; \
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)"; \
ssh $(SSH_USER)@$(host) "docker login -u $(DOCKER_USER) -p $(DOCKER_PASS) $(DOCKER_REGISTRY)"; \
fi; \
2024-06-05 07:29:49 +00:00
if test -n "$(DOCKER_IMAGE)" ; \
then \
ssh $(SSH_USER)@$(host) "docker pull $(DOCKER_IMAGE)"; \
fi; \
)
2023-04-27 07:01:39 +00:00
start-compose-file:
@- echo "\n### starting service(s)"
@- $(foreach host,$(DEPLOY_HOSTS), \
echo "$(host)"; \
ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); docker-compose -f $(DEPLOY_COMPOSE_FILE) -p $(DEPLOY_COMPOSE_PROJECT) up -d"; \
sleep $(DEPLOY_START_DELAY); \
)
2023-04-27 07:01:39 +00:00
stop-compose-file:
@- echo "\n### stopping service(s)"
@- $(foreach host,$(DEPLOY_HOSTS), \
echo "$(host)"; \
ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); docker-compose -f $(DEPLOY_COMPOSE_FILE) -p $(DEPLOY_COMPOSE_PROJECT) down"; \
)
2023-04-27 07:01:39 +00:00
logs-compose-file:
@- echo "\n### logs"
@- ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); docker-compose -f $(DEPLOY_COMPOSE_FILE) -p $(DEPLOY_COMPOSE_PROJECT) logs -f $(service)"
2023-04-27 07:01:39 +00:00
restart-compose-file:
@- $(foreach host,$(DEPLOY_HOSTS), \
echo "$(host)"; \
ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); docker-compose -f $(DEPLOY_COMPOSE_FILE) -p $(DEPLOY_COMPOSE_PROJECT) restart"; \
sleep $(DEPLOY_START_DELAY); \
)