make-deploy/docker.mk

72 lines
1.7 KiB
Makefile
Raw Normal View History

2022-07-08 17:44:23 +00:00
create-docker-contexts:
@- $(foreach host,$(DEPLOY_HOSTS), \
docker context create $(host) --description "$(host)" --docker "host=ssh://$(SSH_USER)@$(host)"; \
)
2022-07-05 06:27:53 +00:00
pre-deploy-compose: pre-deploy-docker
post-deploy-compose: post-deploy-docker
pre-deploy-swarm: pre-deploy-docker
post-deploy-swarm: post-deploy-docker
pre-deploy-docker:
@- echo "\n### running pre-deploy script"
@- $(foreach host,$(DEPLOY_HOSTS), \
ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); sh pre-deploy"; \
)
post-deploy-docker:
@- echo "\n### running post-deploy script"
@- $(foreach host,$(DEPLOY_HOSTS), \
ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); sh post-deploy"; \
)
pull-compose:
@- echo "\n### pulling image(s)"
@- $(foreach ctx,$(DEPLOY_HOSTS), \
docker --context $(ctx) pull $(DOCKER_IMAGE); \
2022-07-05 06:27:53 +00:00
)
pull-swarm:
start-compose:
@- echo "\n### starting service(s)"
@- $(foreach ctx,$(DEPLOY_HOSTS), \
docker-compose --host $(ctx) up -d; \
2022-07-05 06:27:53 +00:00
)
start-swarm:
@- echo "\n### starting service(s)"
@- $(foreach ctx,$(DEPLOY_HOSTS), \
2022-07-15 20:49:40 +00:00
docker --context $(ctx) stack deploy -c stack.yml $(DEPLOY_NAME); \
2022-07-05 06:27:53 +00:00
)
stop-compose:
@- echo "\n### stopping service(s)"
@- $(foreach ctx,$(DEPLOY_HOSTS), \
docker-compose --host $(ctx) down; \
2022-07-05 06:27:53 +00:00
)
stop-swarm:
@- echo "\n### stopping service(s)"
@- $(foreach ctx,$(DEPLOY_HOSTS), \
2022-07-15 20:49:40 +00:00
docker --context $(ctx) stack rm $(DEPLOY_NAME); \
2022-07-05 06:27:53 +00:00
)
logs-compose:
@- echo "\n### logs"
@- docker-compose --host $(ctx) logs -f $(service)
2022-07-05 06:27:53 +00:00
logs-swarm:
@- echo "\n### logs"
@- docker --context $(ctx) service logs -f $(service)
2022-07-05 06:27:53 +00:00
restart-compose:
@- $(foreach ctx,$(DEPLOY_HOSTS), \
docker-compose --host $(ctx) restart; \
2022-07-05 06:27:53 +00:00
)
reload-compose: