2022-09-07 14:48:48 +00:00
|
|
|
# if want our old context back, we need something like that:
|
|
|
|
#stored_ctx = `docker context ls | grep "\*" | cut -d " " -f1`
|
|
|
|
|
|
|
|
stored_ctx = 'default' # HACK
|
|
|
|
|
2022-07-08 17:44:23 +00:00
|
|
|
create-docker-contexts:
|
|
|
|
@- $(foreach host,$(DEPLOY_HOSTS), \
|
2022-11-07 15:57:58 +00:00
|
|
|
echo "$(host)"; \
|
|
|
|
docker context create $(host) --description "$(host)" --docker "host=ssh://$(SSH_USER)@$(host)"; \
|
2022-07-08 17:44:23 +00:00
|
|
|
)
|
2022-09-20 11:13:37 +00:00
|
|
|
|
2022-07-05 06:27:53 +00:00
|
|
|
pull-compose:
|
|
|
|
@- echo "\n### pulling image(s)"
|
|
|
|
@- $(foreach ctx,$(DEPLOY_HOSTS), \
|
2022-11-07 15:57:58 +00:00
|
|
|
echo "$(host)"; \
|
2022-09-20 11:38:18 +00:00
|
|
|
docker context use $(ctx); \
|
|
|
|
if test $(DOCKER_LOGIN) -eq 1 ; \
|
|
|
|
then \
|
|
|
|
docker login -u $(DOCKER_USER) -p $(DOCKER_PASS) $(DOCKER_REGISTRY); \
|
|
|
|
fi; \
|
2022-07-18 14:55:24 +00:00
|
|
|
docker pull $(DOCKER_IMAGE); \
|
2022-07-05 06:27:53 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
pull-swarm:
|
|
|
|
|
|
|
|
start-compose:
|
|
|
|
@- echo "\n### starting service(s)"
|
|
|
|
@- $(foreach ctx,$(DEPLOY_HOSTS), \
|
2022-11-07 15:57:58 +00:00
|
|
|
echo "$(host)"; \
|
2022-07-18 14:55:24 +00:00
|
|
|
docker context use $(ctx); \
|
|
|
|
docker-compose up -d; \
|
2022-07-05 06:27:53 +00:00
|
|
|
)
|
2022-07-18 14:55:24 +00:00
|
|
|
@- docker context use $(stored_ctx)
|
2022-07-05 06:27:53 +00:00
|
|
|
|
|
|
|
start-swarm:
|
|
|
|
@- echo "\n### starting service(s)"
|
|
|
|
@- $(foreach ctx,$(DEPLOY_HOSTS), \
|
2022-11-07 15:57:58 +00:00
|
|
|
echo "$(host)"; \
|
2022-07-15 20:49:40 +00:00
|
|
|
docker --context $(ctx) stack deploy -c stack.yml $(DEPLOY_NAME); \
|
2022-07-05 06:27:53 +00:00
|
|
|
)
|
2022-09-07 09:39:20 +00:00
|
|
|
@- docker context use $(stored_ctx)
|
2022-07-05 06:27:53 +00:00
|
|
|
|
|
|
|
stop-compose:
|
|
|
|
@- echo "\n### stopping service(s)"
|
|
|
|
@- $(foreach ctx,$(DEPLOY_HOSTS), \
|
2022-11-07 15:57:58 +00:00
|
|
|
echo "$(host)"; \
|
2022-07-18 14:55:24 +00:00
|
|
|
docker context use $(ctx); \
|
|
|
|
docker-compose down; \
|
|
|
|
)
|
|
|
|
@- docker context use $(stored_ctx)
|
|
|
|
|
2022-07-05 06:27:53 +00:00
|
|
|
stop-swarm:
|
|
|
|
@- echo "\n### stopping service(s)"
|
|
|
|
@- $(foreach ctx,$(DEPLOY_HOSTS), \
|
2022-11-07 15:57:58 +00:00
|
|
|
echo "$(host)"; \
|
2022-07-15 20:49:40 +00:00
|
|
|
docker --context $(ctx) stack rm $(DEPLOY_NAME); \
|
2022-07-05 06:27:53 +00:00
|
|
|
)
|
2022-07-18 14:55:24 +00:00
|
|
|
@- docker context use $(stored_ctx)
|
|
|
|
|
2022-07-05 06:27:53 +00:00
|
|
|
logs-compose:
|
|
|
|
@- echo "\n### logs"
|
2022-07-18 14:55:24 +00:00
|
|
|
@- docker context use $(host)
|
|
|
|
@- docker-compose logs -f $(service)
|
|
|
|
@- docker context use $(stored_ctx)
|
|
|
|
|
2022-07-05 06:27:53 +00:00
|
|
|
logs-swarm:
|
|
|
|
@- echo "\n### logs"
|
2022-07-18 14:55:24 +00:00
|
|
|
@- docker context use $(DEPLOY_HOSTS)
|
|
|
|
@- docker service logs -f $(service)
|
|
|
|
@- docker context use $(stored_ctx)
|
|
|
|
|
2022-07-05 06:27:53 +00:00
|
|
|
restart-compose:
|
|
|
|
@- $(foreach ctx,$(DEPLOY_HOSTS), \
|
2022-11-07 15:57:58 +00:00
|
|
|
echo "$(host)"; \
|
2022-07-18 14:55:24 +00:00
|
|
|
docker context use $(ctx); \
|
|
|
|
docker-compose restart; \
|
2022-07-05 06:27:53 +00:00
|
|
|
)
|
2022-07-18 14:55:24 +00:00
|
|
|
@- docker context use $(stored_ctx)
|
|
|
|
|
2022-07-05 06:27:53 +00:00
|
|
|
reload-compose:
|