-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver_docker.sh
executable file
·64 lines (57 loc) · 1.74 KB
/
server_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
# This script manages the lifecycle of a Docker container named "kaboom-server".
# It provides functions to start the container in either detached or interactive mode,
# stop the container, and restart the container. The script accepts command-line arguments
# to determine the action to perform.
# Usage:
# ./server_docker.sh [option]
#
# Options:
# -it Start the container in interactive mode.
# -s Stop the container if it is running.
# -r Restart the container.
# (no option) Start the container in detached mode.
#
# The container is configured to map port 22222 on the host to port 22222 in the container.
# It also mounts the following directories and files from the host to the container:
# - $(pwd)/Server to /app/Server
# - $(pwd)/Dictionary to /app/Dictionary
# - $(pwd)/requirements.txt to /app/requirements.txt
#
# The container image used is "kaboom-server:1.0".
#!/bin/bash
CONTAINER_NAME="kaboom-server"
start_detached() {
sudo docker run -d --rm --name $CONTAINER_NAME -p 22222:22222 \
-v $(pwd)/Server:/app/Server \
-v $(pwd)/Dictionary:/app/Dictionary \
-v $(pwd)/requirements.txt:/app/requirements.txt \
kaboom-server:1.0
}
start_interactive() {
sudo docker run -it --rm --name $CONTAINER_NAME -p 22222:22222 \
-v $(pwd)/Server:/app/Server \
-v $(pwd)/Dictionary:/app/Dictionary \
-v $(pwd)/requirements.txt:/app/requirements.txt \
kaboom-server:1.0
}
stop_container() {
sudo docker stop $CONTAINER_NAME
}
restart_container() {
stop_container
start_detached
}
case "$1" in
-it)
start_interactive
;;
-s)
stop_container
;;
-r)
restart_container
;;
*)
start_detached
;;
esac