diff --git a/docker.mk b/docker.mk index b718042..f5f1275 100644 --- a/docker.mk +++ b/docker.mk @@ -1,3 +1,5 @@ +stored_ctx = `docker context ls | grep "\*" | cut -d " " -f1` + create-docker-contexts: @- $(foreach host,$(DEPLOY_HOSTS), \ docker context create $(host) --description "$(host)" --docker "host=ssh://$(SSH_USER)@$(host)"; \ @@ -34,7 +36,6 @@ pull-swarm: start-compose: @- echo "\n### starting service(s)" - @- stored_ctx=`docker context ls | grep "\*" | cut -d " " -f1` @- $(foreach ctx,$(DEPLOY_HOSTS), \ docker context use $(ctx); \ docker-compose up -d; \ @@ -49,7 +50,6 @@ start-swarm: stop-compose: @- echo "\n### stopping service(s)" - @- stored_ctx=`docker context ls | grep "\*" | cut -d " " -f1` @- $(foreach ctx,$(DEPLOY_HOSTS), \ docker context use $(ctx); \ docker-compose down; \ @@ -65,20 +65,17 @@ stop-swarm: logs-compose: @- echo "\n### logs" - @- stored_ctx=`docker context ls | grep "\*" | cut -d " " -f1` @- docker context use $(host) @- docker-compose logs -f $(service) @- docker context use $(stored_ctx) logs-swarm: @- echo "\n### logs" - @- stored_ctx=`docker context ls | grep "\*" | cut -d " " -f1` @- docker context use $(DEPLOY_HOSTS) @- docker service logs -f $(service) @- docker context use $(stored_ctx) restart-compose: - @- stored_ctx=`docker context ls | grep "\*" | cut -d " " -f1` @- $(foreach ctx,$(DEPLOY_HOSTS), \ docker context use $(ctx); \ docker-compose restart; \