-
-
Save austinkelleher/ae592eed024328bb738e3bef4dc0af4c to your computer and use it in GitHub Desktop.
This file contains 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 characters
version: '3' | |
services: | |
test: | |
image: node:8.10 | |
environment: | |
- AWS_REGION=us-east-1 | |
- AWS_ACCESS_KEY_ID=some-id | |
- AWS_SECRET_ACCESS_KEY=some-key | |
- ELASTIC_SEARCH_HOST=elasticsearch:9200 | |
- WAIT_START_CMD=yarn jest | |
- WAIT_SLEEP=10 | |
- WAIT_LOOPS=6 | |
depends_on: | |
- elasticsearch | |
volumes: | |
- ../:/opt/work | |
working_dir: /opt/work | |
command: ./tools/bin/wait_for_elasticsearch_ready | |
elasticsearch: | |
image: docker.elastic.co/elasticsearch/elasticsearch:6.2.4 |
This file contains 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 characters
... | |
Waiting for Elasticsearch in Docker to become ready... | |
Elasticsearch status code: 000 | |
Elasticsearch is not ready yet... | |
Tue May 15 19:50:48 UTC 2018 - waiting to be ready | |
Elasticsearch status code: 000 | |
Elasticsearch is not ready yet... | |
Tue May 15 19:50:58 UTC 2018 - waiting to be ready | |
Elasticsearch status code: 000 | |
Elasticsearch is not ready yet... | |
Tue May 15 19:51:08 UTC 2018 - waiting to be ready | |
Elasticsearch status code: 000 | |
Elasticsearch is not ready yet... | |
Tue May 15 19:51:18 UTC 2018 - waiting to be ready | |
Elasticsearch status code: 000 | |
Elasticsearch is not ready yet... | |
Tue May 15 19:51:28 UTC 2018 - waiting to be ready | |
Elasticsearch status code: 000 | |
Elasticsearch is not ready yet... | |
Tue May 15 19:51:38 UTC 2018 - still not ready, giving up | |
... |
This file contains 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 characters
#!/bin/bash | |
PROJECT_NAME="some-project" | |
docker-compose --log-level DEBUG -p ${PROJECT_NAME} run test | |
EXIT_CODE=${?} | |
docker-compose -p ${PROJECT_NAME} down | |
exit ${EXIT_CODE} |
This file contains 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 characters
#!/bin/bash | |
echo "Waiting for Elasticsearch in Docker to become ready..." | |
URL=http://elasticsearch:9200/_cat/health?h=st | |
is_ready() { | |
STATUS_CODE=$(curl --write-out %{http_code} --silent --output /dev/null $URL) | |
echo "Elasticsearch status code: $STATUS_CODE" | |
if [ $STATUS_CODE -eq "200" ]; then | |
echo "Elasticsearch is ready!" | |
return 0 | |
else | |
echo "Elasticsearch is not ready yet..." | |
return 1 | |
fi | |
} | |
i=0 | |
while ! is_ready; do | |
i=`expr $i + 1` | |
if [ $i -ge $WAIT_LOOPS ]; then | |
echo "$(date) - still not ready, giving up" | |
exit 1 | |
fi | |
echo "$(date) - waiting to be ready" | |
sleep $WAIT_SLEEP | |
done | |
exec $WAIT_START_CMD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was able to solve the connection issue by adding
environment: ['transport.host=127.0.0.1']
to theelasticsearch
service: