-
Notifications
You must be signed in to change notification settings - Fork 0
/
service
executable file
·75 lines (60 loc) · 1.79 KB
/
service
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
#!/bin/bash
echo -e '\033[36m
## .
## ## ## ==
## ## ## ## ===
/""""""""""""""""\___/ ===
\033[36m ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\______/\033[0m'
tput sgr0
USAGE='
service \033[31mstart\033[0m - start the environment
service \033[31mkick\033[0m - restarts the environment
service \033[31mlogs\033[0m - watch the Docker logs
service \033[31mshell\033[0m - runs the container with an interactive shell
service \033[31mbuild\033[0m - build container
'
export DOCKER_BUILDKIT=1
source ./env
function start() {
docker-compose build
CURRENT_UID=$(id -u www-data):$(id -g www-data) docker-compose up --detach --remove-orphans
}
function dev() {
stop
docker-compose build
CURRENT_UID=0:0 docker-compose -f docker-compose.yml -f docker-compose.dev.yml up --remove-orphans -d
}
# start with ./service dev, then run ./service gobuild to rebuild all cmds
function gobuild() {
docker exec -w /src altnet go install -ldflags="-s -w" ./cmd/...
}
function seed() {
echo -e "seeding"
find ./data/altnet -type d -name seed -exec echo {} \;
find ./data/altnet -type d -name seed -print0 | xargs -0 rm -rf
}
function stop() {
echo -e "stopping"
docker-compose down
}
function restart() {
stop && start
}
function console() {
docker exec -e ALTNET_HOST=csokavar -e ALTNET_REAL_USER=encse -e ALTNET_USER=encse -it altnet ./shell
}
function bash() {
docker exec -it altnet /bin/bash
}
function logs() {
docker logs --follow altnet
}
function usage() {
echo -e "$USAGE"
tput sgr0
exit 1
}
if ! type "$1" >/dev/null 2>&1; then usage; else $1; fi