forked from tenforce/docker-virtuoso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·76 lines (53 loc) · 1.83 KB
/
build.sh
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env bash
# Constants and auxiliary functions
# starts containers with the volumes mounted
function wait_for_server_to_boot_on_port()
{
local ip=$1
local sentenceToFindInResponse=$2
if [[ $ip == "" ]]; then
ip="127.0.0.1"
fi
local port=$2
local attempts=0
local max_attempts=60
echo "Waiting for server on $ip:$port to boot up..."
response=$(curl -s $ip:$port)
echo $response
until $(curl --output /dev/null --silent --head --fail http://$ip:$port) || [[ $attempts > $max_attempts ]]; do
attempts=$((attempts+1))
echo "waiting... (${attempts}/${max_attempts})"
sleep 1;
done
if (( $attempts == $max_attempts ));
then
echo "Server on $ip:$port failed to start after $max_attempts"
elif (( $attempts < $max_attempts ));
then
echo "Server on $ip:$port started successfully at attempt (${attempts}/${max_attempts})"
fi
}
# Constants
CONTAINER_NAME="virtuoso-dendro"
CONTAINER_TAG="7.2.4-for-dendro-0.4"
LOCAL_TAG="virtuoso:$CONTAINER_TAG"
COMMITTED_IMAGE_TAG="virtuoso-loaded-with-ontologies"
REPOSITORY_TAG="joaorosilva/virtuoso:$CONTAINER_TAG"
# Destroy container...
docker stop "$CONTAINER_NAME"
docker rm -f "$CONTAINER_NAME"
docker rmi -f "$CONTAINER_NAME"
# Build Container...
docker build -t "$LOCAL_TAG" .
docker run --name "$CONTAINER_NAME" \
"$LOCAL_TAG" &
wait_for_server_to_boot_on_port "127.0.0.1" "8890"
wait_for_server_to_boot_on_port "127.0.0.1" "1111"
docker ps -a
docker exec -i -t "$CONTAINER_NAME" \
/bin/bash -c "/usr/local/virtuoso-opensource/bin/isql-v 1111 -U dba -P dba < /dendro-install/scripts/SQLCommands/declare_namespaces.sql"
docker commit "$CONTAINER_NAME" "$COMMITTED_IMAGE_TAG"
docker tag "$COMMITTED_IMAGE_TAG" "$REPOSITORY_TAG"
# update images
docker push "$REPOSITORY_TAG"
# ./push.sh