-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support create container without docker-compose (#915)
Signed-off-by: Jim Ma <majinjing3@gmail.com>
- Loading branch information
Showing
3 changed files
with
86 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,33 @@ | ||
# Deploying Dragonfly with Docker Compose | ||
# Deploying Dragonfly with Container Directly | ||
|
||
> Currently, docker compose deploying is tested just in single host, no HA support. | ||
## Deploy | ||
## Deploy with Docker Compose | ||
|
||
The `run.sh` script will generate config and deploy all components with `docker-compose`. | ||
|
||
Just run: | ||
|
||
```shell | ||
export IP=<host ip> | ||
./run.sh | ||
``` | ||
|
||
## 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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,71 @@ | ||
#!/bin/sh | ||
|
||
set -xe | ||
set -e | ||
|
||
mkdir -p config | ||
REPO=${REPO:-d7yio} | ||
TAG=${TAG:-latest} | ||
|
||
cat template/cdn.template.json > config/cdn.json | ||
cat template/cdn.template.yaml > config/cdn.yaml | ||
cat template/dfget.template.yaml > config/dfget.yaml | ||
DIR=$(cd "$(dirname "$0")" && pwd) | ||
cd $DIR | ||
|
||
ip=$(hostname -i) | ||
hostname=$(hostname) | ||
prepare(){ | ||
mkdir -p config | ||
|
||
sed -i "s,__IP__,$ip," config/cdn.json | ||
sed -i "s,__IP__,$ip," config/dfget.yaml | ||
sed -i "s,__IP__,$ip," config/cdn.yaml | ||
cat template/cdn.template.json > config/cdn.json | ||
cat template/cdn.template.yaml > config/cdn.yaml | ||
cat template/dfget.template.yaml > config/dfget.yaml | ||
|
||
sed -i "s,__HOSTNAME__,$hostname," config/cdn.json | ||
ip=${IP:-$(hostname -i)} | ||
hostname=$(hostname) | ||
|
||
docker-compose up -d | ||
sed -i "s,__IP__,$ip," config/cdn.json | ||
sed -i "s,__IP__,$ip," config/dfget.yaml | ||
sed -i "s,__IP__,$ip," config/cdn.yaml | ||
|
||
sed -i "s,__HOSTNAME__,$hostname," config/cdn.json | ||
} | ||
|
||
run_container(){ | ||
RUNTIME=${RUNTIME:-docker} | ||
echo use container runtime: ${RUNTIME} | ||
|
||
echo try to clean old containers | ||
${RUNTIME} rm -f dragonfly-cdn dragonfly-scheduler dragonfly-dfdaemon | ||
|
||
printf "create dragonfly-cdn " | ||
${RUNTIME} run -d --name dragonfly-cdn --net=host \ | ||
-v /tmp/log/dragonfly:/var/log/dragonfly \ | ||
-v ${DIR}/config/cdn.yaml:/etc/dragonfly/cdn.yaml \ | ||
-v ${DIR}/config/nginx.conf:/etc/nginx/nginx.conf \ | ||
${REPO}/cdn:${TAG} | ||
|
||
printf "create dragonfly-scheduler " | ||
${RUNTIME} run -d --name dragonfly-scheduler --net=host \ | ||
-v /tmp/log/dragonfly:/var/log/dragonfly \ | ||
-v ${DIR}/config/scheduler.yaml:/etc/dragonfly/scheduler.yaml \ | ||
-v ${DIR}/config/cdn.json:/opt/dragonfly/scheduler-cdn/cdn.json \ | ||
${REPO}/scheduler:${TAG} | ||
|
||
printf "create dragonfly-dfdaemon " | ||
${RUNTIME} run -d --name dragonfly-dfdaemon --net=host \ | ||
-v /tmp/log/dragonfly:/var/log/dragonfly \ | ||
-v ${DIR}/config/dfget.yaml:/etc/dragonfly/dfget.yaml \ | ||
${REPO}/dfdaemon:${TAG} | ||
} | ||
|
||
prepare | ||
|
||
case "$1" in | ||
container) | ||
run_container | ||
;; | ||
|
||
*) | ||
if [ -z "$1" ]; then | ||
docker-compose up -d | ||
exit 0 | ||
fi | ||
echo "unknown argument: $1" | ||
exit 1 | ||
;; | ||
esac |