mirror of https://github.com/codevalet/codevalet
Make the validation of the webapp container a bit more useful
This is almost a liveness probe 🔥
This commit is contained in:
parent
68b1cfae24
commit
b01b105619
|
@ -14,7 +14,7 @@ run: depends monkeys.txt
|
|||
./scripts/ruby bundle exec puma
|
||||
|
||||
check-container: container
|
||||
docker run --rm $(IMAGE_NAME):latest bundle exec puma --version
|
||||
IMAGE_NAME=$(IMAGE_NAME) ./scripts/container-check
|
||||
|
||||
container: depends Dockerfile monkeys.txt
|
||||
docker build -t $(IMAGE_NAME) .
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
NAME=codevalet-webapp-container-check
|
||||
PORT=9292
|
||||
URL=http://127.0.0.1:${PORT}/
|
||||
|
||||
function terminate {
|
||||
echo ">> Terminating ${NAME}"
|
||||
docker stop ${NAME}
|
||||
docker rm ${NAME}
|
||||
}
|
||||
|
||||
trap terminate EXIT
|
||||
|
||||
docker run --detach -p ${PORT}:${PORT} \
|
||||
--name ${NAME} \
|
||||
${IMAGE_NAME}:latest \
|
||||
|
||||
for i in $(seq 1 10); do
|
||||
echo ">> Attempt #${i} to reach ${URL}"
|
||||
curl -sI ${URL} 2>&1 > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
sleep 1
|
||||
else
|
||||
echo '----> :) The app returned a 200'
|
||||
exit 0
|
||||
fi;
|
||||
sleep 1
|
||||
done;
|
||||
|
||||
echo "----> :( Failed to reach the container"
|
||||
|
||||
docker ps
|
||||
# If we get to here without having bailed out, something is wrong
|
||||
exit 1
|
Loading…
Reference in New Issue