-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
92f47aa
commit 9f66ac2
Showing
7 changed files
with
285 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# 根目录 | ||
ROOT_PATH=/e/data | ||
|
||
# 东八区 | ||
TZ=Asia/Shanghai | ||
|
||
# mysql root密码 | ||
MYSQL_ROOT_PASSWORD=234567 | ||
|
||
#redis初始密码 | ||
REDIS_REQUIRE_PASS=234567 | ||
|
||
#后端ENC(mysql)密码 | ||
SPRING_DATASOURCE_PASSWORD=234567 | ||
|
||
#后端ENC(redis)密码 | ||
SPRING_REDIS_PASSWORD=234567 |
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,2 +1,74 @@ | ||
# city-bus-docker-starter | ||
docker启动项目脚本 | ||
|
||
## 安装docker环境 | ||
|
||
```bash | ||
bash install-docker-linux | ||
``` | ||
|
||
## linux下部署项目 | ||
|
||
执行脚本, 自动生成mysql和redis随机密码 | ||
|
||
```bash | ||
bash docker-compose-up-linux.sh | ||
``` | ||
|
||
## Window下部署项目(docker desktop) | ||
|
||
执行脚本, 自动生成mysql和redis随机密码 | ||
|
||
```bash | ||
bash docker-compose-up-window.sh | ||
``` | ||
|
||
## 手工部署项目 | ||
|
||
并修改env内初始密码 | ||
|
||
执行脚本, -d 后台执行 | ||
|
||
```bash | ||
docker-compose up -d | ||
``` | ||
|
||
--- | ||
|
||
## 其他 | ||
|
||
### 注意事项 | ||
|
||
```text | ||
★★★ 容器名称不要使用中横线- ★★★ | ||
``` | ||
|
||
### 如何查看配置 | ||
|
||
```bash | ||
docker-compose config | ||
``` | ||
|
||
### 如何指定文件启动 | ||
|
||
```bash | ||
docker-compose -f docker-compose.yml up -d | ||
或 | ||
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d | ||
``` | ||
|
||
### 关闭并删除项目, 谨慎使用 | ||
|
||
```bash | ||
docker-compose down mysql | ||
``` | ||
|
||
### 默认开启默认端口 | ||
|
||
服务名称 | 端口映射 | ||
------- | ------- | ||
gateway-808 | 0.0.0.0:9010->9010/tcp | ||
gateway-dispatch | 0.0.0.0:8011->8011/tcp | ||
gateway-web | 0.0.0.0:8899->8899/tcp | ||
mysql | 0.0.0.0:9600->3306/tcp, 33060/tcp | ||
redis | 0.0.0.0:9700->6379/tcp | ||
nginx | 0.0.0.0:8080->80/tcp |
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,37 @@ | ||
#!/bin/bash | ||
function generate_passwd(){ | ||
local arr=(a b c d e f g h i g k l m n o p q r s t u v w x y z | ||
A B C D E F G H I G K L M N O P Q R S T U V W X Y Z | ||
! @ ^ 0 1 2 3 4 5 6 7 8 9) | ||
for ((i=0;i<16;i++)) | ||
do | ||
echo -n ${arr[$RANDOM % ${#arr[@]}]} | ||
done | ||
} | ||
|
||
ENV_FILE=my.env | ||
|
||
echo > $ENV_FILE | ||
|
||
MYSQL_PASS=$(generate_passwd) | ||
REDIS_PASS=$(generate_passwd) | ||
|
||
MYSQL_ROOT_PASSWORD=MYSQL_ROOT_PASSWORD=$MYSQL_PASS | ||
SPRING_DATASOURCE_PASSWORD=SPRING_DATASOURCE_PASSWORD=$MYSQL_PASS | ||
|
||
REDIS_REQUIRE_PASS=REDIS_REQUIRE_PASS=$REDIS_PASS | ||
SPRING_REDIS_PASSWORD=SPRING_REDIS_PASSWORD=$REDIS_PASS | ||
|
||
echo "ROOT_PATH=/data" >> $ENV_FILE | ||
|
||
echo "TZ=Asia/Shanghai" >> $ENV_FILE | ||
|
||
echo $MYSQL_ROOT_PASSWORD >> $ENV_FILE | ||
echo $SPRING_DATASOURCE_PASSWORD >> $ENV_FILE | ||
echo $REDIS_REQUIRE_PASS >> $ENV_FILE | ||
echo $SPRING_REDIS_PASSWORD >> $ENV_FILE | ||
|
||
cat $ENV_FILE | ||
|
||
# 初始化并启动项目 | ||
docker-compose --env-file=$ENV_FILE up -d |
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,37 @@ | ||
#!/bin/bash | ||
function generate_passwd(){ | ||
local arr=(a b c d e f g h i g k l m n o p q r s t u v w x y z | ||
A B C D E F G H I G K L M N O P Q R S T U V W X Y Z | ||
! @ ^ 0 1 2 3 4 5 6 7 8 9) | ||
for ((i=0;i<16;i++)) | ||
do | ||
echo -n ${arr[$RANDOM % ${#arr[@]}]} | ||
done | ||
} | ||
|
||
ENV_FILE=my.env | ||
|
||
echo > $ENV_FILE | ||
|
||
MYSQL_PASS=$(generate_passwd) | ||
REDIS_PASS=$(generate_passwd) | ||
|
||
MYSQL_ROOT_PASSWORD=MYSQL_ROOT_PASSWORD=$MYSQL_PASS | ||
SPRING_DATASOURCE_PASSWORD=SPRING_DATASOURCE_PASSWORD=$MYSQL_PASS | ||
|
||
REDIS_REQUIRE_PASS=REDIS_REQUIRE_PASS=$REDIS_PASS | ||
SPRING_REDIS_PASSWORD=SPRING_REDIS_PASSWORD=$REDIS_PASS | ||
|
||
echo "ROOT_PATH=/e/data" >> $ENV_FILE | ||
|
||
echo "TZ=Asia/Shanghai" >> $ENV_FILE | ||
|
||
echo $MYSQL_ROOT_PASSWORD >> $ENV_FILE | ||
echo $SPRING_DATASOURCE_PASSWORD >> $ENV_FILE | ||
echo $REDIS_REQUIRE_PASS >> $ENV_FILE | ||
echo $SPRING_REDIS_PASSWORD >> $ENV_FILE | ||
|
||
cat $ENV_FILE | ||
|
||
# 初始化并启动项目 | ||
docker-compose --env-file=$ENV_FILE up -d |
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,100 @@ | ||
version: "3" | ||
services: | ||
# mysql | ||
mysql: | ||
image: transcodegroup/mysql:2021.07.01 | ||
container_name: mysql | ||
restart: always | ||
ports: | ||
- 9600:3306 | ||
volumes: | ||
- ${ROOT_PATH}/mysql/data:/var/lib/mysql | ||
- ${ROOT_PATH}/mysql/logs:/var/log/mysql | ||
- ${ROOT_PATH}/mysql/backup/database:/mysql/backup/database | ||
- ${ROOT_PATH}/mysql/backup/log:/mysql/backup/log | ||
env_file: | ||
- .env | ||
- my.env | ||
|
||
# redis | ||
redis: | ||
image: redis | ||
container_name: redis | ||
restart: always | ||
ports: | ||
- 9700:6379 | ||
volumes: | ||
- ${ROOT_PATH}/redis/data:/data | ||
#- ${ROOT_PATH}/redis/conf:/usr/local/etc/redis | ||
env_file: | ||
- .env | ||
- my.env | ||
command: redis-server --requirepass ${REDIS_REQUIRE_PASS} | ||
|
||
# spring-boot后端 | ||
gateway_web: | ||
image: transcodegroup/gateway-web | ||
container_name: gateway_web | ||
restart: always | ||
ports: | ||
- 8899:8899 | ||
env_file: | ||
- .env | ||
- my.env | ||
links: | ||
- mysql | ||
- redis | ||
depends_on: | ||
- mysql | ||
- redis | ||
|
||
# spring-boot调度 | ||
gateway_dispatch: | ||
image: transcodegroup/gateway-dispatch | ||
container_name: gateway_dispatch | ||
restart: always | ||
ports: | ||
- 8011:8011 | ||
env_file: | ||
- .env | ||
- my.env | ||
links: | ||
- mysql | ||
- redis | ||
depends_on: | ||
- mysql | ||
- redis | ||
|
||
# gateway-808网关 | ||
gateway_808: | ||
image: 330811792/gateway-808 | ||
container_name: gateway_808 | ||
restart: always | ||
ports: | ||
- 9010:9010 | ||
env_file: | ||
- .env | ||
- my.env | ||
links: | ||
- mysql | ||
- redis | ||
depends_on: | ||
- mysql | ||
- redis | ||
|
||
# nginx前端 | ||
nginx: | ||
image: transcodegroup/nginx | ||
container_name: nginx | ||
restart: always | ||
ports: | ||
- 8080:80 | ||
env_file: | ||
- .env | ||
- my.env | ||
links: | ||
- gateway_web | ||
- gateway_dispatch | ||
depends_on: | ||
- gateway_web | ||
- gateway_dispatch |
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,14 @@ | ||
#!/bin/bash | ||
|
||
curl -fsSL https://get.docker.com | bash -s docker --mirror aliyun | ||
# 开机自启动 | ||
systemctl enable docker | ||
#启动docker | ||
service docker start | ||
|
||
# 运行此命令以下载 Docker Compose 的当前稳定版本: | ||
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | ||
# 对二进制文件应用可执行权限: | ||
sudo chmod +x /usr/local/bin/docker-compose | ||
# 如果docker-compose安装后命令失败,请检查您的路径。您还可以/usr/bin在路径中创建指向或任何其他目录的符号链接。 | ||
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose |
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,7 @@ | ||
|
||
ROOT_PATH=/e/data | ||
TZ=Asia/Shanghai | ||
MYSQL_ROOT_PASSWORD=W0kFBdfavPoT4BK2 | ||
SPRING_DATASOURCE_PASSWORD=W0kFBdfavPoT4BK2 | ||
REDIS_REQUIRE_PASS=GZHMgaqHzag3WuyP | ||
SPRING_REDIS_PASSWORD=GZHMgaqHzag3WuyP |