-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker_run.sh
More file actions
executable file
·67 lines (59 loc) · 1.29 KB
/
Copy pathdocker_run.sh
File metadata and controls
executable file
·67 lines (59 loc) · 1.29 KB
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
#!/bin/bash
# Function to print help message
print_help() {
echo ""
echo "Usage: ./start.sh [OPTIONS]"
echo ""
echo "This script builds and starts the logging-service Docker container."
echo ""
echo "Options:"
echo " --build Rebuild the Docker image before running"
echo " --help Show this help message"
echo ""
}
# Load .env file
if [ -f .env ]; then
export $(grep -v '^#' .env | xargs)
else
echo ".env file not found."
exit 1
fi
# Option handling
BUILD=false
for arg in "$@"
do
case $arg in
--build)
BUILD=true
shift
;;
--help)
print_help
exit 0
;;
*)
echo "Unknown option: $arg"
print_help
exit 1
;;
esac
done
# Optional build step
if [ "$BUILD" = true ]; then
echo "Building Docker image..."
docker build -t logging-service .
echo "Build completed."
fi
# Run Docker container (without volume)
echo "Starting Docker container..."
docker run --rm \
-e SERVER_TYPE=$SERVER_TYPE \
-e PYTHONPATH=src \
-p 3005:3005 \
--network host \
logging-service
# Ask user if unused Docker objects should be pruned
read -p "Do you want to remove all unused Docker objects (images, containers, volumes)? (y/N): " answer
if [[ "$answer" == "y" || "$answer" == "Y" ]]; then
docker system prune
fi