-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
rundev.sh
executable file
·100 lines (92 loc) · 2.23 KB
/
rundev.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env bash
# Copyright © Michal Čihař <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later
set -e
GREEN='\033[0;32m'
NC='\033[0m'
# Used by docker-compose-plugin
WEBLATE_PORT=8080
export WEBLATE_PORT
WEBLATE_HOST=localhost:$WEBLATE_PORT
export WEBLATE_HOST
# Used by docker on start
USER_ID=$(id -u)
export USER_ID
GROUP_ID=$(id -g)
export GROUP_ID
cd dev-docker/
build() {
mkdir -p data
# Build the container
docker compose build --build-arg USER_ID="$USER_ID" --build-arg GROUP_ID="$GROUP_ID"
cat > .env << EOT
USER_ID="$USER_ID"
GROUP_ID="$GROUP_ID"
WEBLATE_PORT="$WEBLATE_PORT"
WEBLATE_HOST="$WEBLATE_HOST"
EOT
}
case $1 in
stop)
docker compose down
;;
logs)
shift
docker compose logs "$@"
;;
compilemessages)
shift
docker compose exec -T -e WEBLATE_ADD_APPS=weblate.billing,weblate.legal weblate weblate compilemessages
;;
test)
shift
docker compose exec -T \
--env CI_BASE_DIR=/tmp \
--env CI_DATABASE=postgresql \
--env CI_DB_HOST=database \
--env CI_DB_NAME=weblate \
--env CI_DB_USER=weblate \
--env CI_DB_PASSWORD=weblate \
--env DJANGO_SETTINGS_MODULE=weblate.settings_test \
weblate weblate collectstatic --noinput
docker compose exec -T \
--env CI_BASE_DIR=/tmp \
--env CI_DATABASE=postgresql \
--env CI_DB_HOST=database \
--env CI_DB_NAME=weblate \
--env CI_DB_USER=weblate \
--env CI_DB_PASSWORD=weblate \
--env DJANGO_SETTINGS_MODULE=weblate.settings_test \
weblate weblate test --noinput "$@"
;;
check)
shift
docker compose exec -T weblate weblate check "$@"
;;
build)
build
;;
wait)
TIMEOUT=0
while ! docker compose ps | grep healthy; do
echo "Waiting for the container startup..."
sleep 5
docker compose ps
TIMEOUT=$((TIMEOUT + 1))
if [ $TIMEOUT -gt 120 ]; then
docker compose logs
exit 1
fi
done
;;
start | restart | "")
build
# Start it up
docker compose up -d --force-recreate
echo -e "\n${GREEN}Running development version of Weblate on http://${WEBLATE_HOST}/${NC}\n"
;;
*)
docker compose "$@"
;;
esac