-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·42 lines (32 loc) · 843 Bytes
/
test.sh
File metadata and controls
executable file
·42 lines (32 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh
set -e
cleanup_docker=0
cleanup_image=0
cleanup() {
set +e
if [ "$cleanup_docker" -ne 0 ]; then
echo "Logs"
docker logs test
echo "Stopping Docker image"
docker stop test
docker rm -f test
fi
if [ "$cleanup_image" -ne 0 ]; then
echo "Removing Docker image"
docker image rm -f testimage
fi
}
trap cleanup EXIT
echo "Building Docker image"
time docker build -t testimage -f test/Dockerfile --build-arg "IMAGE=${CI_REGISTRY_IMAGE}:${TAG}" test
cleanup_image=1
echo "Running Docker image"
docker run -d --name test -e LOG_TO_STDOUT=1 -p 80:80 testimage
cleanup_docker=1
echo "Sleeping"
sleep 5
echo "Testing"
ADDRESS="$(getent hosts docker | awk '{print $1}')"
echo "$ADDRESS site.test" >> /etc/hosts
wget -T 30 -q -O - http://site.test | grep -q '<title>Test site</title>'
echo "Success"