more switches between compose and swarm, preparations for k8s

This commit is contained in:
Andreas Neue 2022-07-04 09:47:18 +02:00
parent e70910bf02
commit 7332150116
1 changed files with 30 additions and 13 deletions

View File

@ -2,21 +2,33 @@
include config.mk include config.mk
create_contexts: create-contexts:
@- $(foreach host,$(DEPLOY_HOSTS), \ @- $(foreach host,$(DEPLOY_HOSTS), \
docker context create $(host) --description "$(host)" --docker "host=ssh://$(SSH_USER)@$(host)"; \ docker context create $(host) --description "$(host)" --docker "host=ssh://$(SSH_USER)@$(host)"; \
) )
deploy: upload pre-deploy pull start post-deploy deploy: upload pre-deploy pull start post-deploy
pre-deploy: pre-deploy: pre-deploy-$(DEPLOY_TYPE)
post-deploy: pst-deploy-$(DEPLOY_TYPE)
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" @- echo "\n### running pre-deploy script"
@- $(foreach host,$(DEPLOY_HOSTS), \ @- $(foreach host,$(DEPLOY_HOSTS), \
cd $(DEPLOY_PATH)/$(DEPLOY_NAME); \ cd $(DEPLOY_PATH)/$(DEPLOY_NAME); \
sh pre-deploy.sh; \ sh pre-deploy.sh; \
) )
post-deploy: post-deploy-docker:
@- echo "\n### running post-deploy script" @- echo "\n### running post-deploy script"
@- $(foreach host,$(DEPLOY_HOSTS), \ @- $(foreach host,$(DEPLOY_HOSTS), \
cd $(DEPLOY_PATH)/$(DEPLOY_NAME); \ cd $(DEPLOY_PATH)/$(DEPLOY_NAME); \
@ -38,10 +50,6 @@ pull:
start: start-$(DEPLOY_TYPE) start: start-$(DEPLOY_TYPE)
stop: stop-$(DEPLOY_TYPE)
logs: logs-$(DEPLOY_TYPE)
start-compose: start-compose:
@- echo "\n### starting service(s)" @- echo "\n### starting service(s)"
@- $(foreach ctx,$(DEPLOY_HOSTS), \ @- $(foreach ctx,$(DEPLOY_HOSTS), \
@ -49,31 +57,40 @@ start-compose:
docker-compose up -d; \ docker-compose up -d; \
) )
start-swarm:
stop: stop-$(DEPLOY_TYPE)
stop-compose: stop-compose:
@- echo "\n### stopping service(s)" @- echo "\n### stopping service(s)"
@- $(foreach ctx,$(DEPLOY_HOSTS), \ @- $(foreach ctx,$(DEPLOY_HOSTS), \
docker context use $(ctx); \ docker context use $(ctx); \
docker-compose down; \ docker-compose down; \
) )
stop-swarm:
logs: logs-$(DEPLOY_TYPE)
logs-compose: logs-compose:
@- echo "\n### logs" @- echo "\n### logs"
@- docker context use $(host) @- docker context use $(host)
@- docker-compose logs -f $(service) @- docker-compose logs -f $(service)
start-swarm:
stop-swarm:
logs-swarm: logs-swarm:
restart: restart: restart-$(DEPLOY_TYPE)
restart-compose:
@- $(foreach ctx,$(DEPLOY_HOSTS), \ @- $(foreach ctx,$(DEPLOY_HOSTS), \
docker context use $(ctx); \ docker context use $(ctx); \
docker-compose restart; \ docker-compose restart; \
) )
reload: reload: reload-$(DEPLOY_TYPE)
reload-compose:
@- $(foreach host,$(DEPLOY_HOSTS), \ @- $(foreach host,$(DEPLOY_HOSTS), \
docker context use $(ctx); \ docker context use $(ctx); \
docker-compose restart; \ docker-compose restart; \