-
-
Save michael-k/00b36c564a40119e55a9742e423e17aa to your computer and use it in GitHub Desktop.
Revisions
-
mixja revised this gist
Nov 30, 2016 . 1 changed file with 3 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,10 @@ # Service health functions # Syntax: $(call check_service_health,<docker-compose-environment>,<service-name>) get_container_id = $$(docker-compose $(1) ps -q $(2)) get_container_state = $$(echo $(call get_container_id,$(1),$(2)) | xargs -I ID docker inspect -f '$(3)' ID) get_service_health = $$(echo $(call get_container_state,$(1),$(2),{{if .State.Running}}{{ .State.Health.Status }}{{end}})) check_service_health = { \ until [[ $(call get_service_health,$(1),$(2)) != starting ]]; \ do sleep 1; \ done; \ if [[ $(call get_service_health,$(1),$(2)) != healthy ]]; \ -
mixja revised this gist
Nov 29, 2016 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,12 @@ # Service health functions # Syntax: $(call check_service_health,<docker-compose-environment>,<service-name>) get_container_id = $$(docker-compose $(1) ps -q $(2)) get_container_state = $$(echo $(call get_container_id,$(1),$(2)) | xargs -I ID docker inspect -f '{{ $(3) }}' ID) get_service_health = $$(echo $(call get_container_state,$(1),$(2),.State.Health.Status)) get_service_running = $$(echo $(call get_container_state,$(1),$(2),.State.Running)) check_service_health = { \ until [[ $(call get_service_health,$(1),$(2)) != starting ]] \ || ($(call get_service_running,$(1),$(2)) = false) ]]; \ do sleep 1; \ done; \ if [[ $(call get_service_health,$(1),$(2)) != healthy ]]; \ -
mixja revised this gist
Nov 25, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,10 +14,10 @@ check_service_health = { \ # $(RELEASE_ARGS) represents the '-p <project> -f <docker-compose-file>' portion of docker-compose command release: # Start mysql container @ docker-compose $(RELEASE_ARGS) up -d mysql # This will wait until mysql container health changes from starting to healthy or unhealthy @ $(call check_service_health,$(RELEASE_ARGS),mysql) # Start nginx container @ docker-compose $(RELEASE_ARGS) up -d nginx # This will wait until nginx container health changes from starting to healthy or unhealthy @ $(call check_service_health,$(RELEASE_ARGS),nginx) -
mixja revised this gist
Nov 25, 2016 . 2 changed files with 9 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ FROM mysql:5.7 HEALTHCHECK --interval=3s --retries=20 CMD mysqlshow -u ${MYSQL_USER} -p${MYSQL_PASSWORD} This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,5 +13,11 @@ check_service_health = { \ # $(RELEASE_ARGS) represents the '-p <project> -f <docker-compose-file>' portion of docker-compose command release: # Start mysql container @ docker-compose up $(RELEASE_ARGS) mysql -d # This will wait until mysql container health changes from starting to healthy or unhealthy @ $(call check_service_health,$(RELEASE_ARGS),mysql) # Start nginx container @ docker-compose up $(RELEASE_ARGS) nginx -d # This will wait until nginx container health changes from starting to healthy or unhealthy @ $(call check_service_health,$(RELEASE_ARGS),nginx) -
mixja revised this gist
Nov 21, 2016 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ FROM nginx HEALTHCHECK --interval=3s --retries=20 CMD curl -fs http://localhost:${HTTP_PORT:-8000} -
mixja created this gist
Nov 21, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ # Service health functions # Syntax: $(call check_service_health,<docker-compose-environment>,<service-name>) get_container_id = $$(docker-compose $(1) ps -q $(2)) get_service_health = $$(echo $(call get_container_id,$(1),$(2)) | xargs -I ID docker inspect -f '{{ .State.Health.Status }}' ID) check_service_health = { \ until [[ $(call get_service_health,$(1),$(2)) != starting ]]; \ do sleep 1; \ done; \ if [[ $(call get_service_health,$(1),$(2)) != healthy ]]; \ then echo $(2) failed health check; exit 1; \ fi; \ } # $(RELEASE_ARGS) represents the '-p <project> -f <docker-compose-file>' portion of docker-compose command release: # This will wait until container health changes from starting to healthy or unhealthy @ $(call check_service_health,$(RELEASE_ARGS),nginx)