make-deploy/docker.mk

70 lines
1.8 KiB
Makefile
Raw Normal View History

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 \
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; \
2022-11-09 11:39:22 +00:00
ssh $(SSH_USER)@$(host) "docker pull $(DOCKER_IMAGE)"; \
2022-07-05 06:27:53 +00:00
)
pull-swarm:
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"; \
2022-07-05 06:27:53 +00:00
)
start-swarm:
@- 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 stack deploy -c stack.yml $(DEPLOY_NAME)"; \
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
stop-swarm:
@- 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) "docker stack rm $(DEPLOY_NAME)"; \
2022-07-05 06:27:53 +00:00
)
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
logs-swarm:
@- echo "\n### logs"
2022-11-09 11:39:22 +00:00
@- ssh $(SSH_USER)@$(host) "docker service 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"; \
2022-07-05 06:27:53 +00:00
)
restart-swarm:
# nop
2022-07-05 06:27:53 +00:00
reload-compose:
@- $(foreach host,$(DEPLOY_HOSTS), \
echo "$(host)"; \
ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); ./reload.sh; \
)
reload-swarm:
@- $(foreach host,$(DEPLOY_HOSTS), \
echo "$(host)"; \
ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); ./reload.sh; \
)