Skip to content

Commit

Permalink
feat: remove deploy without docker compose (#3672)
Browse files Browse the repository at this point in the history
Signed-off-by: Gaius <gaius.qi@gmail.com>
  • Loading branch information
gaius-qi authored Nov 26, 2024
1 parent b83a4c9 commit c220a60
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 117 deletions.
25 changes: 0 additions & 25 deletions deploy/docker-compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,3 @@ export IP=<host ip>
```shell
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
```
118 changes: 26 additions & 92 deletions deploy/docker-compose/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,98 +20,32 @@ prepare(){
sed "s,__IP__,$ip," template/manager.template.yaml > config/manager.yaml
}

delete_container(){
RUNTIME=${RUNTIME:-docker}
echo use container runtime: ${RUNTIME}

echo try to clean old containers
${RUNTIME} rm -f dragonfly-redis dragonfly-mysql dragonfly-manager dragonfly-scheduler \
dragonfly-client dragonfly-seed-client
}

run_container(){
RUNTIME=${RUNTIME:-docker}
echo use container runtime: ${RUNTIME}

echo try to clean old containers
${RUNTIME} rm -f dragonfly-redis dragonfly-mysql dragonfly-manager dragonfly-scheduler \
dragonfly-client dragonfly-seed-client

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}
run() {
# 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
}

prepare

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
run

0 comments on commit c220a60

Please sign in to comment.