Skip to content

Commit

Permalink
Merge pull request #2 from expoli/healthcheck
Browse files Browse the repository at this point in the history
Enable Healthcheck
  • Loading branch information
expoli authored Apr 13, 2020
2 parents c7f7b40 + 5ab92e9 commit 8ac71f6
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 47 deletions.
5 changes: 0 additions & 5 deletions .bolo.env

This file was deleted.

4 changes: 0 additions & 4 deletions .mysql.env

This file was deleted.

75 changes: 47 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# 简介

本项目专注于使用 docker-compsoe 进行容器的编排,实现 bolo 博客的一键启动,以避免广大人民群众在进行 bolo 部署时走不必要的弯路;降低了使用门槛,同时也大大增加了维护与迁移的便利性。
本项目专注于使用 docker-compsoe 进行容器的编排,实现 bolo 博客的一键启动,以避免广大人民群众在进行 bolo 部署时走不必要的弯路;降低了使用门槛,同时也大大增加了维护与迁移的便利性,同时也增加了容器的健康检查机制

**注意:本项目使用 nginx 的反向代理作为 bolo 的 web 服务器、目前支持一键式的http部署(默认占用了80端口)、如若需要启用https访问支持,请自行进行配置。**

Expand Down Expand Up @@ -116,6 +116,8 @@ docker-compose down
sudo rm start-bolo-with-docker-compose -rf
```

![运行结果](image/2020-04-13-docker-compose-ps.png)

### 访问测试

<details>
Expand All @@ -142,13 +144,11 @@ sudo rm start-bolo-with-docker-compose -rf
├── LICENSE
├── mysql # mysql 数据库
│   └── data
├── .mysql.env # mysql 容器环境变量配置文件
├── nginx
│   ├── conf.d # nginx 子配置文件目录、可添加自定义配置文件(以.conf结尾)
│   ├── conf.d/bolo.conf # nginx 子配置文件目录、可添加自定义配置文件(以.conf结尾)
│   ├── nginx.conf
│   └── ssl
├── README.md
├── .bolo.env # bolo 容器环境变量配置文件
├── theme # 主题文件存放路径、如需挂载自定义主题、请在 docker-compose.yaml 中做好相应配置
│   └── solo-nexmoe
└── web
Expand All @@ -161,18 +161,19 @@ sudo rm start-bolo-with-docker-compose -rf
<summary>点击查看docker-compose.yaml</summary>

```yaml
version: "3"
version: "2.4"
services:
nginx:
image: nginx:latest
restart: always
container_name: "solo-nginx"
container_name: "bolo-nginx"
ports:
- "80:80"
# - "443:443"
depends_on:
- "mysql"
bolo:
condition: service_started
links:
- "bolo:bolo"
volumes:
Expand All @@ -182,15 +183,23 @@ services:
- bolo-net
mysql:
image: mysql:5.5
image: mysql:5
restart: always
container_name: "solo-mysql"
container_name: "bolo-mysql"
expose:
- "3306"
volumes:
- ./mysql/data:/var/lib/mysql
env_file:
- ./.mysql.env
environment:
MYSQL_ROOT_PASSWORD: root_passwd
MYSQL_USER: solo
MYSQL_DATABASE: solo
MYSQL_PASSWORD: solo123456
healthcheck:
test: "mysql --user=root --password=root_passwd --execute 'SHOW DATABASES;'"
interval: 2s
timeout: 20s
retries: 10
networks:
- bolo-net
command: --max_allowed_packet=32505856 --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
Expand All @@ -202,15 +211,25 @@ services:
expose:
- "8080"
depends_on:
- "mysql"
mysql:
condition: service_healthy
links:
- "mysql:mysql"
# 主题与文章挂载目录
# volumes:
# - ./web/markdowns:/opt/solo/markdowns:rw
# - ./theme/solo-nexmoe:/opt/solo/skins/nexmoe
env_file:
- ./.bolo.env
environment:
RUNTIME_DB: MYSQL
JDBC_USERNAME: solo
JDBC_PASSWORD: solo123456
JDBC_DRIVER: com.mysql.cj.jdbc.Driver
JDBC_URL: jdbc:mysql://mysql:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
healthcheck:
test: "nc -z localhost 8080 || exit 1"
interval: 10s
timeout: 20s
retries: 10
networks:
- bolo-net
command: --listen_port=8080 --server_scheme=http --server_host=localhost --server_port=
Expand All @@ -223,29 +242,29 @@ networks:

### mysql 容器环境变量

下面是默认的配置、可根据个人需要进行更该、但需要确保与bolo容器的环境变量值一致、保证数据库连接的有效性
下面是默认环境变量的配置、可根据个人需要进行更改、但需要确保与bolo容器的环境变量值一致、确保数据库连接的有效性

```shell
# cat .mysql.env
**注意:你应该将数据库密码修改成强密码!!!**

MYSQL_ROOT_PASSWORD=expoli
MYSQL_USER=solo
MYSQL_DATABASE=solo
MYSQL_PASSWORD=solo123456
```
MYSQL_ROOT_PASSWORD: root_passwd
MYSQL_USER: solo
MYSQL_DATABASE: solo
MYSQL_PASSWORD: solo123456
```
### bolo 容器环境变量
下面是默认的配置、可根据个人需要进行更该、但需要确保与bolo容器的环境变量值一致、保证数据库连接的有效性。
```shell
# cat .bolo.env
**注意:你应该将数据库密码修改成强密码!!!**
RUNTIME_DB=MYSQL
JDBC_USERNAME=solo
JDBC_PASSWORD=solo123456
JDBC_DRIVER=com.mysql.cj.jdbc.Driver
JDBC_URL=jdbc:mysql://mysql:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
```shell
RUNTIME_DB: MYSQL
JDBC_USERNAME: solo
JDBC_PASSWORD: solo123456
JDBC_DRIVER: com.mysql.cj.jdbc.Driver
JDBC_URL: jdbc:mysql://mysql:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
```

</details>
39 changes: 29 additions & 10 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
version: "3"
version: "2.4"

services:
nginx:
image: nginx:latest
restart: always
container_name: "solo-nginx"
container_name: "bolo-nginx"
ports:
- "80:80"
# - "443:443"
depends_on:
- "mysql"
bolo:
condition: service_started
links:
- "bolo:bolo"
volumes:
Expand All @@ -19,15 +20,23 @@ services:
- bolo-net

mysql:
image: mysql:5.5
image: mysql:5
restart: always
container_name: "solo-mysql"
container_name: "bolo-mysql"
expose:
- "3306"
volumes:
- ./mysql/data:/var/lib/mysql
env_file:
- ./.mysql.env
environment:
MYSQL_ROOT_PASSWORD: root_passwd
MYSQL_USER: solo
MYSQL_DATABASE: solo
MYSQL_PASSWORD: solo123456
healthcheck:
test: "mysql --user=root --password=root_passwd --execute 'SHOW DATABASES;'"
interval: 2s
timeout: 20s
retries: 10
networks:
- bolo-net
command: --max_allowed_packet=32505856 --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
Expand All @@ -39,15 +48,25 @@ services:
expose:
- "8080"
depends_on:
- "mysql"
mysql:
condition: service_healthy
links:
- "mysql:mysql"
# 主题与文章挂载目录
# volumes:
# - ./web/markdowns:/opt/solo/markdowns:rw
# - ./theme/solo-nexmoe:/opt/solo/skins/nexmoe
env_file:
- ./.bolo.env
environment:
RUNTIME_DB: MYSQL
JDBC_USERNAME: solo
JDBC_PASSWORD: solo123456
JDBC_DRIVER: com.mysql.cj.jdbc.Driver
JDBC_URL: jdbc:mysql://mysql:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
healthcheck:
test: "nc -z localhost 8080 || exit 1"
interval: 10s
timeout: 20s
retries: 10
networks:
- bolo-net
command: --listen_port=8080 --server_scheme=http --server_host=localhost --server_port=
Expand Down
Binary file added image/2020-04-13-docker-compose-ps.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8ac71f6

Please sign in to comment.