ifdef DOCKER_LOGIN MANDATORY = $(shell printenv MANDATORY) DOCKER_USER DOCKER_PASS DOCKER_REGISTRY endif ifndef DOCKER_LOGIN DOCKER_LOGIN = 0 endif pull-compose: @- echo "\n### pulling image(s)" @- $(foreach host,$(DEPLOY_HOSTS), \ echo "$(host)"; \ if test $(DOCKER_LOGIN) -eq 1 ; \ then \ 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; \ if test -n "$(DOCKER_IMAGE)" ; \ then \ ssh $(SSH_USER)@$(host) "docker pull $(DOCKER_IMAGE)"; \ fi; \ ) start-compose: @- echo "\n### starting service(s)" @- $(foreach host,$(DEPLOY_HOSTS), \ echo "$(host)"; \ ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); docker-compose up -d"; \ sleep $(DEPLOY_START_DELAY); \ ) stop-compose: @- echo "\n### stopping service(s)" @- $(foreach host,$(DEPLOY_HOSTS), \ echo "$(host)"; \ ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); docker-compose down"; \ ) logs-compose: @- echo "\n### logs" @- ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); docker-compose logs -f $(service)" restart-compose: @- $(foreach host,$(DEPLOY_HOSTS), \ echo "$(host)"; \ ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); docker-compose restart"; \ sleep $(DEPLOY_START_DELAY); \ )