-
Notifications
You must be signed in to change notification settings - Fork 1
/
oskari-docker.sh
executable file
·69 lines (65 loc) · 2.35 KB
/
oskari-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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
base="ubuntu:latest"
image="okffi/oskari"
oskaricmd="./run.sh"
# TODO: add persistent data container for postgres separate from the code container http://stackoverflow.com/questions/18496940/how-to-deal-with-persistent-storage-e-g-databases-in-docker
usage() {
echo "Usage: $0 {create|update|updateall|show|build|run|stop} [options]"
echo ""
echo "Utility script for docker-packaged oskari API Server."
echo "Requires that packer and docker are properly installed (See https://packer.io/ or https://docs.docker.com/#installation-guides)"
echo ""
echo "Commands:"
echo " create creates Oskari Server docker image ($image) from ($base) and imports it into local repository"
echo " update updates Oskari Server files from current durectory (copies server folder into /oskari/server in the docker container)"
echo " updateall updates operating system and oskari API Server within docker image"
echo " shell runs docker container in interactive mode with a shell"
echo " show displays installed oskari images and running containers"
echo " list same as show"
echo " start [port] runs Oskari Server at a specified TCP port on the host system"
echo " run [port] same as start"
echo " stop <containerID> stops a running container with containerID (first column in 'show' command output)"
}
rc=255
case "$1" in
create)
packer build -color=false -var "base_image=$base" -var "oskari_image=$image" oskari-create.json
;;
update)
packer build -color=false -var "base_image=$image" -var "oskari_image=$image" oskari-update.json
;;
updateall)
packer build -color=false -var "base_image=$image" -var "oskari_image=$image" oskari-updateos.json
packer build -color=false -var "base_image=$image" -var "oskari_image=$image" oskari-update.json
;;
shell)
docker run -w /oskari -it "$image" /bin/bash
;;
list|show)
echo "\nIMAGES:"
docker images | grep "$image"
echo "\nCONTAINERS (running docker instances):"
docker ps | grep "$image"
;;
start|run)
port=2373
if [ "$2" != "" ]; then
port=$2
fi
docker run -d -w /oskari -p $port:2373 "$image" $oskaricmd
rc=$?
;;
stop)
if [ "$2" = "" ]; then
usage
exit 1
fi
docker stop "$2"
rc=$?
;;
*)
usage
rc=1
;;
esac
exit $rc