diff options
author | Giancarlo Rubio <gianrubio@gmail.com> | 2017-01-24 11:19:44 +0100 |
---|---|---|
committer | Giancarlo Rubio <gianrubio@gmail.com> | 2017-04-12 10:47:21 +0200 |
commit | 14382439345d42c8e6e449c3b271e91296d8a568 (patch) | |
tree | 2c19d6d3a925e89620a660c8d526a19fcb99854e /test_image.sh | |
parent | 6eafa51fa81b24b50dd819a47540db2db8948a39 (diff) | |
download | prometheus_node_collector-14382439345d42c8e6e449c3b271e91296d8a568.tar.bz2 prometheus_node_collector-14382439345d42c8e6e449c3b271e91296d8a568.tar.xz prometheus_node_collector-14382439345d42c8e6e449c3b271e91296d8a568.zip |
test docker image before pushing
Diffstat (limited to 'test_image.sh')
-rwxr-xr-x | test_image.sh | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test_image.sh b/test_image.sh new file mode 100755 index 0000000..c23523a --- /dev/null +++ b/test_image.sh | |||
@@ -0,0 +1,29 @@ | |||
1 | #!/bin/bash | ||
2 | set -exo pipefail | ||
3 | |||
4 | docker_image=$1 | ||
5 | port=$2 | ||
6 | |||
7 | wait_start() { | ||
8 | for in in {1..10}; do | ||
9 | if /usr/bin/curl -s -m 5 -f "http://localhost:${port}/metrics" > /dev/null ; then exit 0 ; | ||
10 | else | ||
11 | sleep 1 | ||
12 | fi | ||
13 | done | ||
14 | |||
15 | exit 1 | ||
16 | |||
17 | } | ||
18 | |||
19 | docker_start() { | ||
20 | docker run -d -p "${port}":"${port}" "${docker_image}" | ||
21 | } | ||
22 | |||
23 | if [[ "$#" -ne 2 ]] ; then | ||
24 | echo "Usage: $0 quay.io/prometheus/node-exporter:v0.13.0 9100" >&2 | ||
25 | exit 1 | ||
26 | fi | ||
27 | |||
28 | docker_start | ||
29 | wait_start | ||