make-deploy/docker.mk

57 lines
1.5 KiB
Makefile

pull-compose:
@- echo "\n### pulling image(s)"
@- $(foreach host,$(DEPLOY_HOSTS), \
echo "$(host)"; \
if test $(DOCKER_LOGIN) -eq 1 ; \
then \
ssh $(SSH_USER)@$(host) "docker login -u $(DOCKER_USER) -p $(DOCKER_PASS) $(DOCKER_REGISTRY)"; \
fi; \
ssh $(SSH_USER)@$(host) "docker pull $(DOCKER_IMAGE)"; \
)
pull-swarm:
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"; \
)
start-swarm:
@- echo "\n### starting service(s)"
@- $(foreach host,$(DEPLOY_HOSTS), \
echo "$(host)"; \
ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); docker stack deploy -c stack.yml $(DEPLOY_NAME)"; \
)
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"; \
)
stop-swarm:
@- echo "\n### stopping service(s)"
@- $(foreach host,$(DEPLOY_HOSTS), \
echo "$(host)"; \
ssh $(SSH_USER)@$(host) "docker stack rm $(DEPLOY_NAME)"; \
)
logs-compose:
@- echo "\n### logs"
@- ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); docker-compose logs -f $(service)"
logs-swarm:
@- echo "\n### logs"
@- ssh $(SSH_USER)@$(host) "docker service logs -f $(service)"
restart-compose:
@- $(foreach host,$(DEPLOY_HOSTS), \
echo "$(host)"; \
ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); docker-compose restart"; \
)
reload-compose: