feat: remove deploy without docker compose (#3672)
Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
parent
b83a4c99de
commit
c220a60464
|
|
@ -20,28 +20,3 @@ export IP=<host ip>
|
||||||
```shell
|
```shell
|
||||||
docker compose down
|
docker compose down
|
||||||
```
|
```
|
||||||
|
|
||||||
## Deploy without Docker Compose
|
|
||||||
|
|
||||||
Just run:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
export IP=<host ip>
|
|
||||||
./run.sh container
|
|
||||||
```
|
|
||||||
|
|
||||||
## Deploy with Other Container Runtime
|
|
||||||
|
|
||||||
Just run:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
export IP=<host ip>
|
|
||||||
export RUNTIME=pouch
|
|
||||||
./run.sh container
|
|
||||||
```
|
|
||||||
|
|
||||||
## Delete containers without docker compose
|
|
||||||
|
|
||||||
```shell
|
|
||||||
./run.sh delete_container
|
|
||||||
```
|
|
||||||
|
|
|
||||||
|
|
@ -20,98 +20,32 @@ prepare(){
|
||||||
sed "s,__IP__,$ip," template/manager.template.yaml > config/manager.yaml
|
sed "s,__IP__,$ip," template/manager.template.yaml > config/manager.yaml
|
||||||
}
|
}
|
||||||
|
|
||||||
delete_container(){
|
run() {
|
||||||
RUNTIME=${RUNTIME:-docker}
|
# start all of docker-compose defined service
|
||||||
echo use container runtime: ${RUNTIME}
|
COMPOSE=docker-compose
|
||||||
|
# use docker compose plugin
|
||||||
|
if docker compose version; then
|
||||||
|
COMPOSE="docker compose"
|
||||||
|
fi
|
||||||
|
|
||||||
echo try to clean old containers
|
$COMPOSE up -d
|
||||||
${RUNTIME} rm -f dragonfly-redis dragonfly-mysql dragonfly-manager dragonfly-scheduler \
|
|
||||||
dragonfly-client dragonfly-seed-client
|
|
||||||
}
|
|
||||||
|
|
||||||
run_container(){
|
# docker-compose version 3 depends_on does not wait for redis and mysql to be “ready” before starting manager ...
|
||||||
RUNTIME=${RUNTIME:-docker}
|
# doc https://docs.docker.com/compose/compose-file/compose-file-v3/#depends_on
|
||||||
echo use container runtime: ${RUNTIME}
|
for i in $(seq 0 10); do
|
||||||
|
service_num=$($COMPOSE ps --services |wc -l)
|
||||||
|
ready_num=$($COMPOSE ps | grep healthy | wc -l)
|
||||||
|
if [ "$service_num" -eq "$ready_num" ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo "wait for all service ready: $ready_num/$service_num,$i times check"
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
echo try to clean old containers
|
# print service list info
|
||||||
${RUNTIME} rm -f dragonfly-redis dragonfly-mysql dragonfly-manager dragonfly-scheduler \
|
$COMPOSE ps
|
||||||
dragonfly-client dragonfly-seed-client
|
exit 0
|
||||||
|
|
||||||
printf "create dragonfly-redis "
|
|
||||||
${RUNTIME} run -d --name dragonfly-redis --restart=always -p 6379:6379 \
|
|
||||||
redis:6-alpine \
|
|
||||||
--requirepass "dragonfly"
|
|
||||||
|
|
||||||
printf "create dragonfly-mysql "
|
|
||||||
${RUNTIME} run -d --name dragonfly-mysql --restart=always -p 3306:3306 \
|
|
||||||
--env MARIADB_USER="dragonfly" \
|
|
||||||
--env MARIADB_PASSWORD="dragonfly" \
|
|
||||||
--env MARIADB_DATABASE="manager" \
|
|
||||||
--env MARIADB_ALLOW_EMPTY_ROOT_PASSWORD="yes" \
|
|
||||||
mariadb:10.6
|
|
||||||
|
|
||||||
printf "create dragonfly-manager "
|
|
||||||
${RUNTIME} run -d --name dragonfly-manager --restart=always --net=host \
|
|
||||||
-v /tmp/log/dragonfly:/var/log/dragonfly \
|
|
||||||
-v ${DIR}/config/manager.yaml:/etc/dragonfly/manager.yaml \
|
|
||||||
${REPO}/manager:${TAG}
|
|
||||||
|
|
||||||
printf "create dragonfly-seed-client "
|
|
||||||
${RUNTIME} run -d --name dragonfly-seed-client --restart=always --net=host \
|
|
||||||
-v /tmp/log/dragonfly:/var/log/dragonfly \
|
|
||||||
-v ${DIR}/config/seed-peer.yaml:/etc/dragonfly/dfget.yaml \
|
|
||||||
${REPO}/client:${CLIENT_TAG}
|
|
||||||
|
|
||||||
printf "create dragonfly-scheduler "
|
|
||||||
${RUNTIME} run -d --name dragonfly-scheduler --restart=always --net=host \
|
|
||||||
-v /tmp/log/dragonfly:/var/log/dragonfly \
|
|
||||||
-v ${DIR}/config/scheduler.yaml:/etc/dragonfly/scheduler.yaml \
|
|
||||||
${REPO}/scheduler:${TAG}
|
|
||||||
|
|
||||||
printf "create dragonfly-client "
|
|
||||||
${RUNTIME} run -d --name dragonfly-client --restart=always --net=host \
|
|
||||||
-v /tmp/log/dragonfly:/var/log/dragonfly \
|
|
||||||
-v ${DIR}/config/dfget.yaml:/etc/dragonfly/dfget.yaml \
|
|
||||||
${REPO}/client:${CLIENT_TAG}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare
|
prepare
|
||||||
|
run
|
||||||
case "$1" in
|
|
||||||
container)
|
|
||||||
run_container
|
|
||||||
;;
|
|
||||||
delete_container)
|
|
||||||
delete_container
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if [ -z "$1" ]; then
|
|
||||||
# start all of docker-compose defined service
|
|
||||||
COMPOSE=docker-compose
|
|
||||||
# use docker compose plugin
|
|
||||||
if docker compose version; then
|
|
||||||
COMPOSE="docker compose"
|
|
||||||
fi
|
|
||||||
|
|
||||||
$COMPOSE up -d
|
|
||||||
|
|
||||||
# docker-compose version 3 depends_on does not wait for redis and mysql to be “ready” before starting manager ...
|
|
||||||
# doc https://docs.docker.com/compose/compose-file/compose-file-v3/#depends_on
|
|
||||||
for i in $(seq 0 10); do
|
|
||||||
service_num=$($COMPOSE ps --services |wc -l)
|
|
||||||
ready_num=$($COMPOSE ps | grep healthy | wc -l)
|
|
||||||
if [ "$service_num" -eq "$ready_num" ]; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
echo "wait for all service ready: $ready_num/$service_num,$i times check"
|
|
||||||
sleep 2
|
|
||||||
done
|
|
||||||
|
|
||||||
# print service list info
|
|
||||||
$COMPOSE ps
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
echo "unknown argument: $1"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue