95 lines
2.3 KiB
Makefile
95 lines
2.3 KiB
Makefile
# if want our old context back, we need something like that:
|
|
#stored_ctx = `docker context ls | grep "\*" | cut -d " " -f1`
|
|
|
|
stored_ctx = 'default' # HACK
|
|
|
|
create-docker-contexts:
|
|
@- $(foreach host,$(DEPLOY_HOSTS), \
|
|
docker context create $(host) --description "$(host)" --docker "host=ssh://$(SSH_USER)@$(host)"; \
|
|
)
|
|
|
|
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.sh"; \
|
|
)
|
|
|
|
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.sh"; \
|
|
)
|
|
|
|
pull-compose:
|
|
@- echo "\n### pulling image(s)"
|
|
@- $(foreach ctx,$(DEPLOY_HOSTS), \
|
|
docker context use $(ctx); \
|
|
docker context use $(ctx); \
|
|
if test $(DOCKER_LOGIN) -eq 1 ; \
|
|
then \
|
|
docker login -u $(DOCKER_USER) -p $(DOCKER_PASS) $(DOCKER_REGISTRY); \
|
|
fi; \
|
|
docker pull $(DOCKER_IMAGE); \
|
|
)
|
|
|
|
pull-swarm:
|
|
|
|
start-compose:
|
|
@- echo "\n### starting service(s)"
|
|
@- $(foreach ctx,$(DEPLOY_HOSTS), \
|
|
docker context use $(ctx); \
|
|
docker-compose up -d; \
|
|
)
|
|
@- docker context use $(stored_ctx)
|
|
|
|
start-swarm:
|
|
@- echo "\n### starting service(s)"
|
|
@- $(foreach ctx,$(DEPLOY_HOSTS), \
|
|
docker --context $(ctx) stack deploy -c stack.yml $(DEPLOY_NAME); \
|
|
)
|
|
@- docker context use $(stored_ctx)
|
|
|
|
stop-compose:
|
|
@- echo "\n### stopping service(s)"
|
|
@- $(foreach ctx,$(DEPLOY_HOSTS), \
|
|
docker context use $(ctx); \
|
|
docker-compose down; \
|
|
)
|
|
@- docker context use $(stored_ctx)
|
|
|
|
stop-swarm:
|
|
@- echo "\n### stopping service(s)"
|
|
@- $(foreach ctx,$(DEPLOY_HOSTS), \
|
|
docker --context $(ctx) stack rm $(DEPLOY_NAME); \
|
|
)
|
|
@- docker context use $(stored_ctx)
|
|
|
|
logs-compose:
|
|
@- echo "\n### logs"
|
|
@- docker context use $(host)
|
|
@- docker-compose logs -f $(service)
|
|
@- docker context use $(stored_ctx)
|
|
|
|
logs-swarm:
|
|
@- echo "\n### logs"
|
|
@- docker context use $(DEPLOY_HOSTS)
|
|
@- docker service logs -f $(service)
|
|
@- docker context use $(stored_ctx)
|
|
|
|
restart-compose:
|
|
@- $(foreach ctx,$(DEPLOY_HOSTS), \
|
|
docker context use $(ctx); \
|
|
docker-compose restart; \
|
|
)
|
|
@- docker context use $(stored_ctx)
|
|
|
|
reload-compose:
|