docker compose scripts for CI build on jenkins

Start script for rabbitmq
Stop script for rabbitmq
rabbitmq docker image configuration
This commit is contained in:
Soby Chacko
2016-10-27 19:53:56 -04:00
committed by Marius Bogoevici
parent 84bf88bb25
commit 6a1da546ef
3 changed files with 88 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
#!/bin/bash
LOCAL_HOST="${LOCAL_HOST:-localhost}"
RETRIES="${RETRIES:-70}"
PORT_TO_CHECK=5672
WAIT_TIME="${WAIT_TIME:-5}"
function netcat_port() {
local PASSED_HOST="${2:-$LOCAL_HOST}"
local RABBITMQ_STOPPED=1
local counter=1
for i in $( seq 1 "${RETRIES}" ); do
((counter++))
if [ "${counter}" -gt 2 ]
then
echo "Rabbitmq is still running. Will try to stop again in [${WAIT_TIME}] seconds"
fi
sleep "${WAIT_TIME}"
nc -v -w 1 ${PASSED_HOST} $1 && continue
echo "Rabbitmq stopped..."
RABBITMQ_STOPPED=0
break
done
return ${RABBITMQ_STOPPED}
}
export -f netcat_port
dockerComposeFile="docker-compose-RABBITMQ.yml"
docker-compose -f $dockerComposeFile kill
RABBITMQ_STOPPED="no"
echo "Waiting for RabbitMQ to stop for [$(( WAIT_TIME * RETRIES ))] seconds"
netcat_port $PORT_TO_CHECK && RABBITMQ_STOPPED="yes"
if [[ "${RABBITMQ_STOPPED}" == "no" ]] ; then
echo "RabbitMQ failed to stop..."
exit 1
fi

View File

@@ -0,0 +1,41 @@
#!/bin/bash
LOCAL_HOST="${LOCAL_HOST:-localhost}"
SHOULD_START_RABBIT="${SHOULD_START_RABBIT:-yes}"
PORT_TO_CHECK=5672
WAIT_TIME="${WAIT_TIME:-5}"
RETRIES="${RETRIES:-70}"
function netcat_port() {
local PASSED_HOST="${2:-$LOCAL_HOST}"
local READY_FOR_TESTS=1
for i in $( seq 1 "${RETRIES}" ); do
sleep "${WAIT_TIME}"
nc -v -w 1 ${PASSED_HOST} $1 && READY_FOR_TESTS=0 && break
echo "Fail #$i/${RETRIES}... will try again in [${WAIT_TIME}] seconds"
done
return ${READY_FOR_TESTS}
}
export -f netcat_port
dockerComposeFile="docker-compose-RABBITMQ.yml"
docker-compose -f $dockerComposeFile kill
docker-compose -f $dockerComposeFile build
if [[ "${SHOULD_START_RABBIT}" == "yes" ]] ; then
echo -e "\n\nBooting up RabbitMQ"
docker-compose -f $dockerComposeFile up -d rabbitmq
fi
READY_FOR_TESTS="no"
echo "Waiting for RabbitMQ to boot for [$(( WAIT_TIME * RETRIES ))] seconds"
netcat_port $PORT_TO_CHECK && READY_FOR_TESTS="yes"
if [[ "${READY_FOR_TESTS}" == "no" ]] ; then
echo "RabbitMQ failed to start..."
exit 1
fi

View File

@@ -0,0 +1,5 @@
rabbitmq:
image: rabbitmq:management
ports:
- 5672:5672
- 15672:15672