Skip to content

Commit c220a60

Browse files
authored
feat: remove deploy without docker compose (#3672)
Signed-off-by: Gaius <gaius.qi@gmail.com>
1 parent b83a4c9 commit c220a60

File tree

2 files changed

+26
-117
lines changed

2 files changed

+26
-117
lines changed

deploy/docker-compose/README.md

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,3 @@ export IP=<host ip>
2020
```shell
2121
docker compose down
2222
```
23-
24-
## Deploy without Docker Compose
25-
26-
Just run:
27-
28-
```shell
29-
export IP=<host ip>
30-
./run.sh container
31-
```
32-
33-
## Deploy with Other Container Runtime
34-
35-
Just run:
36-
37-
```shell
38-
export IP=<host ip>
39-
export RUNTIME=pouch
40-
./run.sh container
41-
```
42-
43-
## Delete containers without docker compose
44-
45-
```shell
46-
./run.sh delete_container
47-
```

deploy/docker-compose/run.sh

Lines changed: 26 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -20,98 +20,32 @@ prepare(){
2020
sed "s,__IP__,$ip," template/manager.template.yaml > config/manager.yaml
2121
}
2222

23-
delete_container(){
24-
RUNTIME=${RUNTIME:-docker}
25-
echo use container runtime: ${RUNTIME}
26-
27-
echo try to clean old containers
28-
${RUNTIME} rm -f dragonfly-redis dragonfly-mysql dragonfly-manager dragonfly-scheduler \
29-
dragonfly-client dragonfly-seed-client
30-
}
31-
32-
run_container(){
33-
RUNTIME=${RUNTIME:-docker}
34-
echo use container runtime: ${RUNTIME}
35-
36-
echo try to clean old containers
37-
${RUNTIME} rm -f dragonfly-redis dragonfly-mysql dragonfly-manager dragonfly-scheduler \
38-
dragonfly-client dragonfly-seed-client
39-
40-
printf "create dragonfly-redis "
41-
${RUNTIME} run -d --name dragonfly-redis --restart=always -p 6379:6379 \
42-
redis:6-alpine \
43-
--requirepass "dragonfly"
44-
45-
printf "create dragonfly-mysql "
46-
${RUNTIME} run -d --name dragonfly-mysql --restart=always -p 3306:3306 \
47-
--env MARIADB_USER="dragonfly" \
48-
--env MARIADB_PASSWORD="dragonfly" \
49-
--env MARIADB_DATABASE="manager" \
50-
--env MARIADB_ALLOW_EMPTY_ROOT_PASSWORD="yes" \
51-
mariadb:10.6
52-
53-
printf "create dragonfly-manager "
54-
${RUNTIME} run -d --name dragonfly-manager --restart=always --net=host \
55-
-v /tmp/log/dragonfly:/var/log/dragonfly \
56-
-v ${DIR}/config/manager.yaml:/etc/dragonfly/manager.yaml \
57-
${REPO}/manager:${TAG}
58-
59-
printf "create dragonfly-seed-client "
60-
${RUNTIME} run -d --name dragonfly-seed-client --restart=always --net=host \
61-
-v /tmp/log/dragonfly:/var/log/dragonfly \
62-
-v ${DIR}/config/seed-peer.yaml:/etc/dragonfly/dfget.yaml \
63-
${REPO}/client:${CLIENT_TAG}
64-
65-
printf "create dragonfly-scheduler "
66-
${RUNTIME} run -d --name dragonfly-scheduler --restart=always --net=host \
67-
-v /tmp/log/dragonfly:/var/log/dragonfly \
68-
-v ${DIR}/config/scheduler.yaml:/etc/dragonfly/scheduler.yaml \
69-
${REPO}/scheduler:${TAG}
70-
71-
printf "create dragonfly-client "
72-
${RUNTIME} run -d --name dragonfly-client --restart=always --net=host \
73-
-v /tmp/log/dragonfly:/var/log/dragonfly \
74-
-v ${DIR}/config/dfget.yaml:/etc/dragonfly/dfget.yaml \
75-
${REPO}/client:${CLIENT_TAG}
23+
run() {
24+
# start all of docker-compose defined service
25+
COMPOSE=docker-compose
26+
# use docker compose plugin
27+
if docker compose version; then
28+
COMPOSE="docker compose"
29+
fi
30+
31+
$COMPOSE up -d
32+
33+
# docker-compose version 3 depends_on does not wait for redis and mysql to be “ready” before starting manager ...
34+
# doc https://docs.docker.com/compose/compose-file/compose-file-v3/#depends_on
35+
for i in $(seq 0 10); do
36+
service_num=$($COMPOSE ps --services |wc -l)
37+
ready_num=$($COMPOSE ps | grep healthy | wc -l)
38+
if [ "$service_num" -eq "$ready_num" ]; then
39+
break
40+
fi
41+
echo "wait for all service ready: $ready_num/$service_num,$i times check"
42+
sleep 2
43+
done
44+
45+
# print service list info
46+
$COMPOSE ps
47+
exit 0
7648
}
7749

7850
prepare
79-
80-
case "$1" in
81-
container)
82-
run_container
83-
;;
84-
delete_container)
85-
delete_container
86-
;;
87-
*)
88-
if [ -z "$1" ]; then
89-
# start all of docker-compose defined service
90-
COMPOSE=docker-compose
91-
# use docker compose plugin
92-
if docker compose version; then
93-
COMPOSE="docker compose"
94-
fi
95-
96-
$COMPOSE up -d
97-
98-
# docker-compose version 3 depends_on does not wait for redis and mysql to be “ready” before starting manager ...
99-
# doc https://docs.docker.com/compose/compose-file/compose-file-v3/#depends_on
100-
for i in $(seq 0 10); do
101-
service_num=$($COMPOSE ps --services |wc -l)
102-
ready_num=$($COMPOSE ps | grep healthy | wc -l)
103-
if [ "$service_num" -eq "$ready_num" ]; then
104-
break
105-
fi
106-
echo "wait for all service ready: $ready_num/$service_num,$i times check"
107-
sleep 2
108-
done
109-
110-
# print service list info
111-
$COMPOSE ps
112-
exit 0
113-
fi
114-
echo "unknown argument: $1"
115-
exit 1
116-
;;
117-
esac
51+
run

0 commit comments

Comments
 (0)