-
Notifications
You must be signed in to change notification settings - Fork 1
/
build
executable file
·54 lines (41 loc) · 1.04 KB
/
build
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
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
## Exit immediately on error.
set -e
# Echo to console.
set -x
cleanup_test_containers() {
CONTAINERS=$(docker ps -a -q --filter "name=sia-test-container")
if [ ! -z $CONTAINERS ]; then
docker stop $CONTAINERS
docker rm $CONTAINERS
fi
}
cleanup_test_containers
for DIR in ./ ./alpine ./pi
do
echo "Building image: $DIR"
docker build \
--tag sia-image \
-f $DIR/Dockerfile \
.
export DUMMY_DATA_DIR=$(mktemp -d)
# Run container in detached state
docker run \
--detach \
--publish 127.0.0.1:9988:9980 \
--volume "${DUMMY_DATA_DIR}:/sia-data" \
--env SIA_MODULES=cg \
--name sia-test-container \
sia-image
sleep 5s
if [ -e "${DUMMY_DATA_DIR}/consensus" ]; then
(echo "Created consensus folder successfully" && exit 0)
else
(echo "Couldn't find consensus folder for image at $DIR" && \
docker logs sia-test-container && \
exit 1)
fi
curl -A "Sia-Agent" "http://localhost:9988/consensus"
docker rm -f sia-test-container
done
cleanup_test_containers