forked from nirv-ai/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.refresh.compose.sh
More file actions
executable file
·39 lines (32 loc) · 907 Bytes
/
script.refresh.compose.sh
File metadata and controls
executable file
·39 lines (32 loc) · 907 Bytes
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
#!/usr/bin/env bash
set -euo pipefail
dk_ps() {
docker ps --no-trunc -a --format 'table {{.Names}}\n\t{{.Image}}\n\t{{.Status}}\n\t{{.Command}}\n\n' | tac
}
save_canonical_compose_config() {
dk_ps
echo -e "\nforcing .env.compose.[yaml, json] in current dir"
docker compose convert | yq -r -o=json >.env.compose.json
docker compose convert >.env.compose.yaml
}
service_restart_all() {
echo -e "restarting all containers"
docker compose up -d --force-recreate
save_canonical_compose_config
}
service_restart() {
service_name=$1
rebuild_image=${2:-0}
dk_up_flags='-d --force-recreate'
if [ "$rebuild_image" == "1" ]; then
echo 'also rebuilding container image'
dk_up_flags="$dk_up_flags --build"
fi
docker compose up $dk_up_flags $service_name
save_canonical_compose_config
}
cmd=${1:-'all'}
case $cmd in
all) service_restart_all ;;
*) service_restart "$@" ;;
esac