-
Notifications
You must be signed in to change notification settings - Fork 157
/
docker-compose-build-upgrade.sh
52 lines (40 loc) · 1.07 KB
/
docker-compose-build-upgrade.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
#!/usr/bin/env bash
usage() {
echo "Usage: $0 [-f <path to docker-compose file>]" 1>&2
exit 1
}
DOCKER_COMPOSE_FILE=docker-compose-build.yml
while getopts ":f:" o; do
case "${o}" in
f)
if [[ -f "${OPTARG}" ]]; then
DOCKER_COMPOSE_FILE=${OPTARG}
else
echo "File not found"
fi
;;
*)
usage
;;
esac
done
shift $((OPTIND - 1))
prepare_meta_file() {
VERSION=$(git describe --tags --always)
BUILD=$(git rev-parse --short HEAD)
echo "CISO_ASSISTANT_VERSION=${VERSION}" >.meta
echo "CISO_ASSISTANT_BUILD=${BUILD}" >>.meta
cp .meta ./backend/ciso_assistant/.meta
cp .meta ./backend/.meta
}
prepare_meta_file
# Remove old container and images
docker compose rm -fs
docker rmi -f $(docker images -aq -f reference=ciso-assistant*)
# Build and start the containers
docker compose -f "${DOCKER_COMPOSE_FILE}" build
docker compose -f "${DOCKER_COMPOSE_FILE}" up -d
# Perform database migrations
docker compose exec backend python manage.py migrate
echo "Connect to CISO Assistant on https://localhost:8443"
echo "For successive runs, you can now use 'docker compose up'."