-
-
Save wainersm/c2c578a4487a6da7af5017c442ebbc3d to your computer and use it in GitHub Desktop.
Logstash - CI design using docker compose.
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
diff --git a/qa/integration/services/dockerized/Dockerfile b/qa/integration/services/dockerized/Dockerfile | |
new file mode 100644 | |
index 0000000..491a883 | |
--- /dev/null | |
+++ b/qa/integration/services/dockerized/Dockerfile | |
@@ -0,0 +1,19 @@ | |
+FROM debian:stretch | |
+ | |
+ENV _JAVA_OPTIONS "-Djava.net.preferIPv4Stack=true" | |
+ENV TERM=linux | |
+ | |
+RUN apt-get update && apt-get install -y curl openjdk-8-jre-headless netcat | |
+ | |
+RUN adduser --disabled-password --gecos '' tester | |
+USER tester | |
+ENV SANDBOX /home/tester | |
+WORKDIR $SANDBOX | |
+ | |
+ADD helpers.sh . | |
+ | |
+ONBUILD ADD setup.sh . | |
+ONBUILD ADD run.sh . | |
+ONBUILD RUN ./setup.sh | |
+ | |
+CMD ["./run.sh"] | |
diff --git a/qa/integration/services/dockerized/docker-compose.yml b/qa/integration/services/dockerized/docker-compose.yml | |
new file mode 100644 | |
index 0000000..9d43aeb | |
--- /dev/null | |
+++ b/qa/integration/services/dockerized/docker-compose.yml | |
@@ -0,0 +1,12 @@ | |
+version: '2' | |
+ | |
+services: | |
+ sandbox: | |
+ build: . | |
+ image: logstash_ci_sandbox | |
+ command: [/bin/bash, -i] | |
+ elasticsearch: | |
+ build: ./elasticsearch | |
+ ports: | |
+ - "127.0.0.1:9200:9200" | |
+ - "127.0.0.1:9300:9300" | |
diff --git a/qa/integration/services/dockerized/elasticsearch/Dockerfile b/qa/integration/services/dockerized/elasticsearch/Dockerfile | |
new file mode 100644 | |
index 0000000..f3cfe54 | |
--- /dev/null | |
+++ b/qa/integration/services/dockerized/elasticsearch/Dockerfile | |
@@ -0,0 +1,3 @@ | |
+FROM logstash_ci_sandbox | |
+ | |
+expose 9200 9300 | |
diff --git a/qa/integration/services/dockerized/elasticsearch/run.sh b/qa/integration/services/dockerized/elasticsearch/run.sh | |
new file mode 100755 | |
index 0000000..80b7e29 | |
--- /dev/null | |
+++ b/qa/integration/services/dockerized/elasticsearch/run.sh | |
@@ -0,0 +1,17 @@ | |
+#!/bin/bash | |
+set -ex | |
+current_dir="$(dirname "$0")" | |
+ | |
+ES_HOME=${SANDBOX}/elasticsearch | |
+ | |
+${ES_HOME}/bin/elasticsearch $es_args -E http.host=0.0.0.0 & | |
+count=20 | |
+ echo "Waiting for elasticsearch to respond..." | |
+ while ! curl --silent localhost:9200 && [[ $count -ne 0 ]]; do | |
+ count=$(( $count - 1 )) | |
+ [[ $count -eq 0 ]] && return 1 | |
+ sleep 1 | |
+ done | |
+ echo "Elasticsearch is Up !" | |
+ | |
+tail -f /dev/null | |
diff --git a/qa/integration/services/dockerized/elasticsearch/setup.sh b/qa/integration/services/dockerized/elasticsearch/setup.sh | |
new file mode 100755 | |
index 0000000..05e7b24 | |
--- /dev/null | |
+++ b/qa/integration/services/dockerized/elasticsearch/setup.sh | |
@@ -0,0 +1,19 @@ | |
+#!/bin/bash | |
+set -ex | |
+current_dir="$(dirname "$0")" | |
+ | |
+source "$current_dir/helpers.sh" | |
+ | |
+if [ -n "${ES_VERSION+1}" ]; then | |
+ echo "Elasticsearch version is $ES_VERSION" | |
+ version=$ES_VERSION | |
+else | |
+ version=5.0.1 | |
+fi | |
+ | |
+ES_HOME=${SANDBOX}/elasticsearch | |
+ | |
+download_url=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$version.tar.gz | |
+curl -s -o elasticsearch.tar.gz $download_url > elasticsearch.tar.gz | |
+mkdir -p $ES_HOME | |
+tar -xzf elasticsearch.tar.gz --strip-components=1 -C $ES_HOME/. | |
diff --git a/qa/integration/services/dockerized/helpers.sh b/qa/integration/services/dockerized/helpers.sh | |
new file mode 100644 | |
index 0000000..6a08a5d | |
--- /dev/null | |
+++ b/qa/integration/services/dockerized/helpers.sh | |
@@ -0,0 +1,15 @@ | |
+#!/bin/bash | |
+set -e | |
+ | |
+PORT_WAIT_COUNT=20 | |
+wait_for_port() { | |
+ count=$PORT_WAIT_COUNT | |
+ port=$1 | |
+ while ! nc -z localhost $port && [[ $count -ne 0 ]]; do | |
+ count=$(( $count - 1 )) | |
+ [[ $count -eq 0 ]] && return 1 | |
+ sleep 0.5 | |
+ done | |
+ # just in case, one more time | |
+ nc -z localhost $port | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment