This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
81 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Deploy | ||
|
||
All files in this directory are only used for CI/CD purposes. But you can also manually use these scripts or configurations in the right place. | ||
|
||
# Introduction | ||
|
||
## docker-entrypoint.sh | ||
|
||
only use for docker build, **DO NOT EDIT OR MOVE.** | ||
|
||
## restart-service.sh | ||
|
||
this shell file is used for start/restart the specific service (**list: api user follow interaction video chat**) | ||
|
||
```bash | ||
sh restart-service.sh api # or others | ||
``` | ||
|
||
- the container use **host** network | ||
- you need to **move config.yaml** to the same dir as this file | ||
- **Before starting the service**, you need to configure the corresponding environment (refer to the configuration in config.yaml). | ||
- The script will **automatically** detect and delete the containers, no manual deletion is required. | ||
|
||
## Others | ||
|
||
- restart-service-all.sh: no further explanation is needed. | ||
- common.sh: set any constants | ||
- remove-all-containers: common scripts |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
|
||
IMAGE_NAME="registry.cn-hangzhou.aliyuncs.com/ozline/tiktok:v1" | ||
|
||
DIR=$(cd $(dirname $0); pwd) |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/sh | ||
source common.sh | ||
|
||
containers_to_stop=$(docker ps -aq --filter "ancestor=$IMAGE_NAME") | ||
|
||
for container_id in $containers_to_stop; do | ||
container_status=$(docker inspect -f '{{.State.Status}}' "$container_id") | ||
if [ "$container_status" == "running" ]; then | ||
echo "Stopping container $container_id..." | ||
docker stop "$container_id" | ||
elif [ "$container_status" == "paused" ]; then | ||
echo "Unpausing and then stopping container $container_id..." | ||
docker unpause "$container_id" | ||
docker stop "$container_id" | ||
fi | ||
echo "Remove container $container_id..." | ||
docker rm "$container_id" | ||
done |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/sh | ||
source remove-all-containers.sh | ||
|
||
echo "Pulling the latest image..." | ||
docker pull "$IMAGE_NAME" | ||
|
||
echo "Launch all services" | ||
for service in api user chat follow interaction video; do | ||
echo "Starting container for $service..." | ||
docker run -d --name "tiktok-$service" \ | ||
-e service=$service \ | ||
--net=host \ | ||
-v $DIR/config:/app/config \ | ||
"$IMAGE_NAME" | ||
done |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
source remove-all-containers.sh | ||
|
||
SERVICE_TO_START=${1:-api} # get specific service | ||
|
||
echo "Starting container for $SERVICE_TO_START..." | ||
docker run -d --name "tiktok-$SERVICE_TO_START" \ | ||
-e service=$SERVICE_TO_START \ | ||
--net=host \ | ||
-v $DIR/config:/app/config \ | ||
"$IMAGE_NAME" |