Skip to content

Commit

Permalink
Merge pull request #363 from jhu-idc/tm--replace-s6-drupal-status-wit…
Browse files Browse the repository at this point in the history
…h-docker-healthcheck

Tm  replace s6 drupal status with docker healthcheck
  • Loading branch information
springstim authored Dec 22, 2022
2 parents 389cbe6 + d28777c commit b0fdf41
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ RUN \
COMPOSER_MEMORY_LIMIT=-1 COMPOSER_DISCARD_CHANGES=true composer install --no-interaction --no-progress --prefer-dist && \
composer clearcache

HEALTHCHECK --start-period=3m --retries=10 --timeout=5s --interval=15s CMD curl -o /dev/null -s -H "Host:$( echo $DRUPAL_DEFAULT_SITE_URL | sed s,^.*/,, )" http://localhost:80/ || exit 1

# /init process must be run as root:
USER root
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ field_name: field_alternative_title
entity_type: node
type: language_value_pair
settings:
max_length: '500'
max_length: '5000'
is_ascii: false
case_sensitive: false
target_type: taxonomy_term
Expand Down
29 changes: 25 additions & 4 deletions idc.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,33 @@ start:
.SILENT: _docker-up-and-wait
_docker-up-and-wait:
docker-compose up -d
sleep 5
containerId="" ; \
while [ -z "$$containerId" ] ; do \
echo "(still) waiting for Drupal container to appear" ; \
sleep 2; \
containerId=$$( docker-compose ps -q drupal ) ; \
done && echo "containerId='$$containerId'"
# composer config can move forward since container is available:
if [ "${GH_TOKEN}" ]; then \
echo "Installing github token"; \
docker-compose exec -T drupal bash -lc "composer config -g github-oauth.github.com ${GH_TOKEN}" && echo '' ; \
fi;
docker-compose exec -T drupal /bin/sh -c "while true ; do echo \"Waiting for Drupal to start ...\" ; if [ -d \"/var/run/s6/services/nginx\" ] ; then s6-svwait -u /var/run/s6/services/nginx && exit 0 ; else sleep 5 ; fi done"
docker-compose exec -T drupal bash -lc "composer config -g github-oauth.github.com ${GH_TOKEN}" ; \
else \
echo "No github token provided" ; \
fi
# new block:
containerId=$$( docker-compose ps -q drupal ) ; \
echo "Drupal container ID: '$$containerId'" ; \
containerName=$$(docker inspect -f '{{.Name}}' $$(docker-compose ps -q drupal) | cut -c2-) ; \
echo "Looking into run-state of found-container '$$containerName'" ; \
if [ -n "$$containerName" ] ; then \
runState="" ; \
while [ "true" != "$$runState" ] ; do \
sleep 5 ; \
runState=$$(docker inspect -f {{.State.Running}} "$$containerName") ; \
echo "Waiting for Drupal to start ... current state: $$runState" ; \
done && \
echo Drupal is ready. ; \
fi

# Static drupal image, with codebase baked in. This image
# is tagged based on the current git hash/tag. If the image is not present
Expand Down

0 comments on commit b0fdf41

Please sign in to comment.