mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-12-28 06:59:44 -08:00
Merge pull request #435 from gianrubio/test-image
Test docker image before pushing
This commit is contained in:
commit
636c88adf7
4
Makefile
4
Makefile
|
@ -76,6 +76,10 @@ docker:
|
||||||
@echo ">> building docker image"
|
@echo ">> building docker image"
|
||||||
@docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" .
|
@docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" .
|
||||||
|
|
||||||
|
test-docker:
|
||||||
|
@echo ">> testing docker image"
|
||||||
|
./test_image.sh "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" 9100
|
||||||
|
|
||||||
$(GOPATH)/bin/promu promu:
|
$(GOPATH)/bin/promu promu:
|
||||||
@GOOS= GOARCH= $(GO) get -u github.com/prometheus/promu
|
@GOOS= GOARCH= $(GO) get -u github.com/prometheus/promu
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ dependencies:
|
||||||
test:
|
test:
|
||||||
override:
|
override:
|
||||||
- docker run --rm -t -v "$(pwd):/app" "${DOCKER_TEST_IMAGE_NAME}" -i "${REPO_PATH}" -T
|
- docker run --rm -t -v "$(pwd):/app" "${DOCKER_TEST_IMAGE_NAME}" -i "${REPO_PATH}" -T
|
||||||
|
- make test-docker
|
||||||
|
|
||||||
deployment:
|
deployment:
|
||||||
hub_branch:
|
hub_branch:
|
||||||
|
|
29
test_image.sh
Executable file
29
test_image.sh
Executable file
|
@ -0,0 +1,29 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -exo pipefail
|
||||||
|
|
||||||
|
docker_image=$1
|
||||||
|
port=$2
|
||||||
|
|
||||||
|
wait_start() {
|
||||||
|
for in in {1..10}; do
|
||||||
|
if /usr/bin/curl -s -m 5 -f "http://localhost:${port}/metrics" > /dev/null ; then exit 0 ;
|
||||||
|
else
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
docker_start() {
|
||||||
|
docker run -d -p "${port}":"${port}" "${docker_image}"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "$#" -ne 2 ]] ; then
|
||||||
|
echo "Usage: $0 quay.io/prometheus/node-exporter:v0.13.0 9100" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker_start
|
||||||
|
wait_start
|
Loading…
Reference in a new issue