-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenable_air.sh
75 lines (56 loc) · 2.02 KB
/
enable_air.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
#!/bin/bash
if [ "$1" == "start" ]; then
# If the argument is "start", bring the containers up only with build
docker compose up -d --build
fi
if [ "$1" == "restart" ]; then
# If the argument is "start", bring the containers down and then up
docker compose down --remove-orphans
docker compose up -d --build
fi
if [ "$1" == "clean" ]; then
# If the argument is "clean", clean the host docker and build all
docker system prune
docker volume prune
docker image prune
docker-compose down --remove-orphans
docker-compose up -d --build
fi
# start air directly once docker container is set up
if [ "$1" == "air" ]; then
docker exec -it go-api sh -c "go install github.com/cosmtrek/air@latest"
docker exec -it go-api sh -c "air init"
# Modify .air.toml to set poll = true
docker exec -it go-api sed -i 's/poll = false/poll = true/' .air.toml
docker exec -it go-api sh -c "air -c .air.toml"
fi
# start only air init once docker container is set up
if [ "$1" == "air-init" ]; then
docker exec -it go-api sh -c "air init"
# Modify .air.toml to set poll = true
docker exec -it go-api sed -i 's/poll = false/poll = true/' .air.toml
docker exec -it go-api sh -c "air -c .air.toml"
fi
# start air with installing it and build
if [ "$2" == "air" ]; then
docker exec -it go-api sh -c "go install github.com/cosmtrek/air@latest"
docker exec -it go-api sh -c "air init"
# Modify .air.toml to set poll = true
docker exec -it go-api sed -i 's/poll = false/poll = true/' .air.toml
docker exec -it go-api sh -c "air -c .air.toml"
fi
# start only air init
if [ "$2" == "air-init" ]; then
docker exec -it go-api sh -c "air init"
# Modify .air.toml to set poll = true
docker exec -it go-api sed -i 's/poll = false/poll = true/' .air.toml
docker exec -it go-api sh -c "air -c .air.toml"
fi
# Restart air without build directly if a container is already up
if [ "$1" == "restart-air" ]; then
docker exec -it go-api sh -c "air -c .air.toml"
fi
# Restart air without build
if [ "$1" == "restart-air" ]; then
docker exec -it go-api sh -c "air -c .air.toml"
fi