-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker.sh
executable file
·47 lines (38 loc) · 1.13 KB
/
docker.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
#!/usr/bin/env bash
# build the DecisionToolkit binary
cargo +stable build --release --target x86_64-unknown-linux-musl
# set the container name
NAME=dsntk
# set the container version taken from DecisionToolkit binary
VERSION=$(cargo +stable run --release --target x86_64-unknown-linux-musl -- --version)
# remove existing Docker container
echo ""
container_id="$(docker container list -af name=dsntk -q)"
if [ -z "$container_id" ]
then
echo "$NAME container not found, skipping deletion"
else
echo "$NAME container found, deleting"
docker rm -f "$container_id"
echo "$NAME container deleted"
fi
echo ""
# remove existing Docker image
echo ""
image_id="$(docker images -f reference=$NAME -q)"
if [ -z "$image_id" ]
then
echo "$NAME image not found, skipping deletion"
else
echo "$NAME image found, deleting"
docker rmi "$image_id"
echo "$NAME image deleted"
fi
echo ""
# build new Docker image
docker build -t "$NAME:$VERSION" .
# start new Docker container
docker run --name $NAME -d -p 22022:22022 "$NAME:$VERSION"
# display logs from running Docker container
docker logs -f "$NAME"
# press Ctrl+C to stop following the log file :)