-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_template.sh
52 lines (42 loc) · 1.26 KB
/
build_template.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
#!/bin/sh
########################################################
######## Build and run a Docker image for Larex ########
########################################################
## Container name (must be lower case)
CONTAINER_NAME="larex"
## Image name
IMAGE_NAME="larex"
## Local path to the directory containing the books
BOOK_DIR="/Path/to/books"
## Local path to the directory containing the books
## Ignored if empty!
SAVE_DIR=""
## Local path to the custom configuration file
CONFIG_FILE="/Path/to/larex.properties"
## Port
PORT=5555
## Stop and delete old container (if exists)
OLD="$(docker ps --all --quiet --filter=name="${DOCKER_NAME}")"
if [[ -n "$OLD" ]]; then
docker stop ${OLD} && docker rm ${OLD}
fi
## Build and start container
docker build -t ${IMAGE_NAME} . && \
if [ -z "${SAVE_DIR}" ]
then
docker run \
-p ${PORT}:8080 \
--name ${DOCKER_NAME} \
-v ${CONFIG_FILE}:/default.properties \
-v ${BOOK_DIR}:/home/books/ \
-v ${SAVE_DIR}:/home/savedir \
-it ${IMAGE_NAME}
else
docker run \
-p ${PORT}:8080 \
--name ${DOCKER_NAME} \
-v ${CONFIG_FILE}:/default.properties \
-v ${BOOK_DIR}:/home/books/ \
-v ${SAVE_DIR}:/home/savedir \
-it ${IMAGE_NAME}
fi