-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed docker entrypoint, added more checks, added example
- Loading branch information
1 parent
034c9b5
commit f471163
Showing
22 changed files
with
228 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
FROM alpine:3.8 | ||
|
||
RUN apk --update add python3 py3-tornado py3-argparse bash perl curl wget grep sed | ||
RUN apk --update add python3 py3-tornado py3-argparse bash perl curl wget grep sed docker sudo | ||
ADD ./app/ /app | ||
ADD ./entrypoint.sh /entrypoint.sh | ||
RUN chmod +x /entrypoint.sh | ||
|
||
# tests | ||
RUN set -x && cd /app && ./test.sh | ||
|
||
ENTRYPOINT ["/bin/bash", "-c", "cd /app && python3 ./infracheck/bin.py --server --server-port 8000 $@"] | ||
ENTRYPOINT ["/entrypoint.sh"] |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/sh | ||
|
||
# | ||
# Directory presence check | ||
# | ||
# @author Krzysztof Wesołowski | ||
# @url https://iwa-ait.org | ||
# | ||
|
||
if [[ ! ${DIR} ]]; then | ||
echo "DIR parameter is missing" | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -d ${DIR} ]]; then | ||
echo "Failed asserting that directory at '${DIR}' is present" | ||
exit 1 | ||
fi | ||
|
||
echo "'${DIR}' directory is present" | ||
exit 0 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/sh | ||
|
||
# | ||
# Docker services status check | ||
# | ||
# @author Krzysztof Wesołowski | ||
# @url https://iwa-ait.org | ||
# | ||
|
||
if ! command -v docker > /dev/null; then | ||
echo "Docker command is not available, cannot perform a check without it" | ||
exit 1 | ||
fi | ||
|
||
output=$(docker ps --filter "name=${DOCKER_ENV_NAME}" --filter "health=unhealthy" 2>&1|grep "unhealthy") | ||
exit_code=$? | ||
|
||
if [[ ${exit_code} == 0 ]]; then | ||
echo "There seems to be at least one unhealthy service at '${DOCKER_ENV_NAME}' space" | ||
docker ps --filter "name=${DOCKER_ENV_NAME}" --filter "health=unhealthy" | ||
exit 1 | ||
fi | ||
|
||
echo "Docker daemon reports that there is no 'unhealthy' service running in '${DOCKER_ENV_NAME}' space" | ||
exit 0 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/sh | ||
|
||
# | ||
# File presence check | ||
# | ||
# @author Krzysztof Wesołowski | ||
# @url https://iwa-ait.org | ||
# | ||
|
||
if [[ ! ${FILE_PATH} ]]; then | ||
echo "FILE_PATH parameter is missing" | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -f ${FILE_PATH} ]]; then | ||
echo "Failed asserting that file at '${FILE_PATH}' is present" | ||
exit 1 | ||
fi | ||
|
||
echo "'${FILE_PATH}' file is present" | ||
exit 0 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/sh | ||
|
||
# | ||
# File presence check | ||
# | ||
# @author Krzysztof Wesołowski | ||
# @url https://iwa-ait.org | ||
# | ||
|
||
if [[ ! ${PO_HOST} ]] || [[ ! ${PO_PORT} ]] || [[ ! ${PO_TIMEOUT} ]]; then | ||
echo "PO_HOST, PO_PORT or PO_TIMEOUT parameter is missing" | ||
exit 1 | ||
fi | ||
|
||
if ! nc -z -v -w${PO_TIMEOUT} ${PO_HOST} ${PO_PORT}; then | ||
echo "Port ${PO_PORT} at ${PO_HOST} seems to be not active" | ||
exit 1 | ||
fi | ||
|
||
echo "Port ${PO_PORT} at ${PO_HOST} looks OK" | ||
exit 0 |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"type": "dir-present", | ||
"input": { | ||
"dir": "/data" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"type": "docker-health", | ||
"input": { | ||
"docker_env_name": "" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"type": "file-present", | ||
"input": { | ||
"file_path": "/usr/bin/env" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"type": "port-open", | ||
"input": { | ||
"po_port": "80", | ||
"po_host": "google.com", | ||
"po_timeout": "1" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
cd /app | ||
exec python3 ./infracheck/bin.py --server --server-port 8000 $@ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
InfraCheck example | ||
================== | ||
|
||
```bash | ||
sudo docker-compose up -d | ||
curl http://localhost:8000/some-prefix/ | ||
|
||
# debugging | ||
sudo docker-compose logs | ||
|
||
# enjoy! | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: '2' | ||
services: | ||
healthcheck: | ||
image: wolnosciowiec/infracheck | ||
command: " --directory=/data --server-path-prefix=/some-prefix" | ||
volumes: | ||
# place your health checks structure at ./healthchecks | ||
- "./healthchecks:/data" | ||
- "/var/run/docker.sock:/var/run/docker.sock:ro" | ||
ports: | ||
- "8000:8000" |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
echo "Hello! This is an example check, you can write your own 'check' scripts that takes parameters from JSON and environment variables" | ||
echo "The word is: ${WORD}" | ||
env | ||
|
||
exit 0 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "disk-space", | ||
"input": { | ||
"dir": "/", | ||
"min_req_space": "6" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"type": "docker-health", | ||
"input": { | ||
"docker_env_name": "" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
example/healthchecks/configured/hello-test-custom-check-example.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"type": "hello", | ||
"input": { | ||
"word": "Hi there, Im a passed parameter" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"type": "http", | ||
"input": { | ||
"url": "https://duckduckgo.com", | ||
"expect_keyword": "duck", | ||
"not_expect_keyword": "Server error" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"type": "port-open", | ||
"input": { | ||
"po_port": "80", | ||
"po_host": "iwa-ait.org", | ||
"po_timeout": "1" | ||
} | ||
} |