generated from CS3219-AY2324S1/course-assessment-template
-
Notifications
You must be signed in to change notification settings - Fork 5
/
start_containers.sh
29 lines (23 loc) · 1.06 KB
/
start_containers.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
#!/bin/bash
# Exit immediately if a command exits with a non-zero status.
set -e
# Directory of this script.
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Run the below code relative to this script's directory.
cd "$SCRIPT_DIR"
# Check if volumes already exist, if not create them.
if [ "$(docker volume ls | grep users-data)" == "" ]; then
docker volume create users-data
fi
if [ "$(docker volume ls | grep questions-data)" == "" ]; then
docker volume create questions-data
fi
if [ "$(docker volume ls | grep nginx_logs)" == "" ]; then
docker volume create nginx_logs
docker run --rm -v nginx_logs:/nginx_logs nginx touch "./nginx_logs/access_file.log"
fi
# Remove CR (ie. \r) characters from `judge0.conf`, as judge0 server crashes if
# it does; and Git keeps adding them back when Git's `autocrlf` is set to "input".
sed -i 's/\r//g' "./backend_services/code_execution_service/judge0/judge0.conf"
# Rebuild and (re)start the services, removing orphan containers in the process.
docker compose --env-file .env up --build --remove-orphans "$@"