|
|
|
@ -9,23 +9,23 @@ description: 使用 Docker Compose 部署
|
|
|
|
|
|
|
|
|
|
## 创建容器组
|
|
|
|
|
|
|
|
|
|
可用的 Halo 2.0.0-rc.1 的 Docker 镜像:
|
|
|
|
|
可用的 Halo 2.0.0 的 Docker 镜像:
|
|
|
|
|
|
|
|
|
|
- [halohub/halo-dev](https://hub.docker.com/r/halohub/halo-dev)
|
|
|
|
|
- [ghcr.io/halo-dev/halo-dev](https://github.com/halo-dev/halo/pkgs/container/halo-dev)
|
|
|
|
|
- [halohub/halo](https://hub.docker.com/r/halohub/halo)
|
|
|
|
|
- [ghcr.io/halo-dev/halo](https://github.com/halo-dev/halo/pkgs/container/halo)
|
|
|
|
|
|
|
|
|
|
:::info 注意
|
|
|
|
|
以上两个镜像仅作为 Halo 2.0 测试期间的镜像,正式发布之后会更改为 `halohub/halo` 和 `ghcr.io/halo-dev/halo`。
|
|
|
|
|
目前 Halo 2.0 并未更新 Docker 的 latest 标签镜像,主要因为 2.0 不兼容 1.x 版本,防止使用者误操作。我们推荐使用固定版本的标签,比如 `halohub/halo:2.0.0`。
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
|
|
1. 在系统任意位置创建一个文件夹,此文档以 `~/halo-next` 为例。
|
|
|
|
|
1. 在系统任意位置创建一个文件夹,此文档以 `~/halo` 为例。
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
mkdir ~/halo-next && cd ~/halo-next
|
|
|
|
|
mkdir ~/halo && cd ~/halo
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
:::info
|
|
|
|
|
注意:后续操作中,Halo 的所有相关数据都会保存在这个目录,请妥善保存。
|
|
|
|
|
注意:后续操作中,Halo 产生的所有数据都会保存在这个目录,请妥善保存。
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
|
|
2. 创建 `docker-compose.yaml`
|
|
|
|
@ -36,41 +36,74 @@ description: 使用 Docker Compose 部署
|
|
|
|
|
需要注意的是,此文档为了更加方便的管理配置,所有与 Halo 相关的配置都使用 Docker 环境变量代替,所以无需创建 application.yaml 文件。
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
|
|
1. 仅创建 Halo 实例(使用默认的 H2 数据库):
|
|
|
|
|
1. 创建 Halo + PostgreSQL 的实例:
|
|
|
|
|
|
|
|
|
|
```yaml {13-20}
|
|
|
|
|
```yaml {18-28,46} title="~/halo/docker-compose.yaml"
|
|
|
|
|
version: "3"
|
|
|
|
|
|
|
|
|
|
services:
|
|
|
|
|
halo_next:
|
|
|
|
|
image: halohub/halo-dev:2.0.0-rc.1
|
|
|
|
|
container_name: halo_next
|
|
|
|
|
halo:
|
|
|
|
|
image: halohub/halo:2.0.0
|
|
|
|
|
container_name: halo
|
|
|
|
|
restart: on-failure:3
|
|
|
|
|
depends_on:
|
|
|
|
|
halodb:
|
|
|
|
|
condition: service_healthy
|
|
|
|
|
networks:
|
|
|
|
|
halo_network:
|
|
|
|
|
volumes:
|
|
|
|
|
- ./:/root/.halo2
|
|
|
|
|
ports:
|
|
|
|
|
- "8090:8090"
|
|
|
|
|
environment:
|
|
|
|
|
- SPRING_R2DBC_URL=r2dbc:pool:postgresql://halodb/halo
|
|
|
|
|
- SPRING_R2DBC_USERNAME=halo
|
|
|
|
|
# PostgreSQL 的密码,请保证与下方 POSTGRES_PASSWORD 的变量值一致。
|
|
|
|
|
- SPRING_R2DBC_PASSWORD=openpostgresql
|
|
|
|
|
- SPRING_SQL_INIT_PLATFORM=postgresql
|
|
|
|
|
# 外部访问地址,请根据实际需要修改
|
|
|
|
|
- HALO_EXTERNAL_URL=http://localhost:8090/
|
|
|
|
|
# 初始化的超级管理员用户名
|
|
|
|
|
- HALO_SECURITY_INITIALIZER_SUPERADMINUSERNAME=admin
|
|
|
|
|
# 初始化的超级管理员密码
|
|
|
|
|
- HALO_SECURITY_INITIALIZER_SUPERADMINPASSWORD=P@88w0rd
|
|
|
|
|
|
|
|
|
|
halodb:
|
|
|
|
|
image: postgres:latest
|
|
|
|
|
container_name: halodb
|
|
|
|
|
restart: on-failure:3
|
|
|
|
|
networks:
|
|
|
|
|
halo_network:
|
|
|
|
|
volumes:
|
|
|
|
|
- ./db:/var/lib/postgresql/data
|
|
|
|
|
ports:
|
|
|
|
|
- "5432:5432"
|
|
|
|
|
healthcheck:
|
|
|
|
|
test: [ "CMD", "pg_isready" ]
|
|
|
|
|
interval: 10s
|
|
|
|
|
timeout: 5s
|
|
|
|
|
retries: 5
|
|
|
|
|
environment:
|
|
|
|
|
- POSTGRES_PASSWORD=openpostgresql
|
|
|
|
|
- POSTGRES_USER=halo
|
|
|
|
|
- POSTGRES_DB=halo
|
|
|
|
|
|
|
|
|
|
networks:
|
|
|
|
|
halo_network:
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
2. 创建 Halo + PostgreSQL 的实例:
|
|
|
|
|
2. 创建 Halo + MySQL 的实例:
|
|
|
|
|
|
|
|
|
|
```yaml {18-28,46}
|
|
|
|
|
```yaml
|
|
|
|
|
version: "3"
|
|
|
|
|
|
|
|
|
|
services:
|
|
|
|
|
halo_next:
|
|
|
|
|
image: halohub/halo-dev:2.0.0-rc.1
|
|
|
|
|
container_name: halo_next
|
|
|
|
|
halo:
|
|
|
|
|
image: halohub/halo:2.0.0
|
|
|
|
|
container_name: halo
|
|
|
|
|
restart: on-failure:3
|
|
|
|
|
depends_on:
|
|
|
|
|
halo_db:
|
|
|
|
|
halodb:
|
|
|
|
|
condition: service_healthy
|
|
|
|
|
networks:
|
|
|
|
|
halo_network:
|
|
|
|
@ -79,11 +112,11 @@ description: 使用 Docker Compose 部署
|
|
|
|
|
ports:
|
|
|
|
|
- "8090:8090"
|
|
|
|
|
environment:
|
|
|
|
|
- SPRING_R2DBC_URL=r2dbc:pool:postgresql://halo_db/halo
|
|
|
|
|
- SPRING_R2DBC_USERNAME=halo
|
|
|
|
|
# PostgreSQL 的密码,请保证与下方 POSTGRES_PASSWORD 的变量值一致。
|
|
|
|
|
- SPRING_R2DBC_PASSWORD=openpostgresql
|
|
|
|
|
- SPRING_SQL_INIT_PLATFORM=postgresql
|
|
|
|
|
- SPRING_R2DBC_URL=r2dbc:pool:mysql://halodb:3306/halo
|
|
|
|
|
- SPRING_R2DBC_USERNAME=root
|
|
|
|
|
# MySQL 的密码,请保证与下方 MYSQL_ROOT_PASSWORD 的变量值一致。
|
|
|
|
|
- SPRING_R2DBC_PASSWORD=o#DwN&JSa56
|
|
|
|
|
- SPRING_SQL_INIT_PLATFORM=mysql
|
|
|
|
|
# 外部访问地址,请根据实际需要修改
|
|
|
|
|
- HALO_EXTERNAL_URL=http://localhost:8090/
|
|
|
|
|
# 初始化的超级管理员用户名
|
|
|
|
@ -91,48 +124,110 @@ description: 使用 Docker Compose 部署
|
|
|
|
|
# 初始化的超级管理员密码
|
|
|
|
|
- HALO_SECURITY_INITIALIZER_SUPERADMINPASSWORD=P@88w0rd
|
|
|
|
|
|
|
|
|
|
halo_db:
|
|
|
|
|
image: postgres:latest
|
|
|
|
|
container_name: halo_db
|
|
|
|
|
halodb:
|
|
|
|
|
image: mysql:8.0.27
|
|
|
|
|
container_name: halodb
|
|
|
|
|
restart: on-failure:3
|
|
|
|
|
networks:
|
|
|
|
|
halo_network:
|
|
|
|
|
command: --default-authentication-plugin=mysql_native_password
|
|
|
|
|
--character-set-server=utf8mb4
|
|
|
|
|
--collation-server=utf8mb4_general_ci
|
|
|
|
|
--explicit_defaults_for_timestamp=true
|
|
|
|
|
volumes:
|
|
|
|
|
- ./db:/var/lib/postgresql/data
|
|
|
|
|
- ./mysql:/var/lib/mysql
|
|
|
|
|
- ./mysqlBackup:/data/mysqlBackup
|
|
|
|
|
ports:
|
|
|
|
|
- "5432:5432"
|
|
|
|
|
- "3306:3306"
|
|
|
|
|
healthcheck:
|
|
|
|
|
test: [ "CMD", "pg_isready" ]
|
|
|
|
|
interval: 10s
|
|
|
|
|
timeout: 5s
|
|
|
|
|
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent"]
|
|
|
|
|
interval: 3s
|
|
|
|
|
retries: 5
|
|
|
|
|
start_period: 30s
|
|
|
|
|
environment:
|
|
|
|
|
- POSTGRES_PASSWORD=openpostgresql
|
|
|
|
|
- POSTGRES_USER=halo
|
|
|
|
|
- POSTGRES_DB=halo
|
|
|
|
|
# 请修改此密码,并对应修改上方 Halo 服务的 SPRING_R2DBC_PASSWORD 变量值
|
|
|
|
|
- MYSQL_ROOT_PASSWORD=o#DwN&JSa56
|
|
|
|
|
- MYSQL_DATABASE=halo
|
|
|
|
|
|
|
|
|
|
networks:
|
|
|
|
|
halo_network:
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
3. 仅创建 Halo 实例(使用默认的 H2 数据库,**不推荐用于生产环境,建议体验和测试的时候使用**):
|
|
|
|
|
|
|
|
|
|
```yaml {13-20} title="~/halo/docker-compose.yaml"
|
|
|
|
|
version: "3"
|
|
|
|
|
|
|
|
|
|
services:
|
|
|
|
|
halo:
|
|
|
|
|
image: halohub/halo:2.0.0
|
|
|
|
|
container_name: halo
|
|
|
|
|
restart: on-failure:3
|
|
|
|
|
volumes:
|
|
|
|
|
- ./:/root/.halo2
|
|
|
|
|
ports:
|
|
|
|
|
- "8090:8090"
|
|
|
|
|
environment:
|
|
|
|
|
# 外部访问地址,请根据实际需要修改
|
|
|
|
|
- HALO_EXTERNAL_URL=http://localhost:8090/
|
|
|
|
|
# 初始化的超级管理员用户名
|
|
|
|
|
- HALO_SECURITY_INITIALIZER_SUPERADMINUSERNAME=admin
|
|
|
|
|
# 初始化的超级管理员密码
|
|
|
|
|
- HALO_SECURITY_INITIALIZER_SUPERADMINPASSWORD=P@88w0rd
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
3. 启动 Halo 服务
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
docker-compose up -d
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
实时查看日志:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
docker-compose logs -f
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
4. 用浏览器访问 `$HALO_EXTERNAL_URL/console/`(外部访问链接)即可进入 Halo 管理端。管理员用户名为 `admin`,登录密码为上方设置的 `HALO_SECURITY_INITIALIZER_SUPERADMINPASSWORD`。
|
|
|
|
|
|
|
|
|
|
:::tip
|
|
|
|
|
如果需要配置域名访问,建议先配置好反向代理以及域名解析再进行初始化。如果通过 `http://ip:端口号` 的形式无法访问,请到服务器厂商后台将运行的端口号添加到安全组,如果服务器使用了 Linux 面板,请检查此 Linux 面板是否有还有安全组配置,需要同样将端口号添加到安全组。
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
|
|
## 使用
|
|
|
|
|
## 更新容器组
|
|
|
|
|
|
|
|
|
|
1. 停止运行中的容器组
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
cd ~/halo && docker-compose down
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
2. 备份数据(重要)
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
cp -r ~/halo ~/halo.archive
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
目前 RC 版本有以下几个使用注意事项:
|
|
|
|
|
> 需要注意的是,`halo.archive` 文件名不一定要根据此文档命名,这里仅仅是个示例。
|
|
|
|
|
|
|
|
|
|
1. 由于目前评论组件被插件化且暂不支持提供默认插件,所以如果要体验完整的评论功能,需要手动在后台安装 <https://github.com/halo-sigs/plugin-comment-widget> 评论组件插件。
|
|
|
|
|
2. 目前 2.0 已支持的主题和插件会同步到 <https://github.com/halo-sigs/awesome-halo>,你可以在对应仓库的 release 下载最新的主题或插件。
|
|
|
|
|
3. 更新 Halo 服务
|
|
|
|
|
|
|
|
|
|
修改 `docker-compose.yaml` 中配置的镜像版本。
|
|
|
|
|
|
|
|
|
|
```yaml {3}
|
|
|
|
|
services:
|
|
|
|
|
halo:
|
|
|
|
|
image: halohub/halo:2.0.0
|
|
|
|
|
container_name: halo
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
docker-compose pull
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
docker-compose up -d
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 反向代理
|
|
|
|
|
|
|
|
|
@ -140,7 +235,7 @@ description: 使用 Docker Compose 部署
|
|
|
|
|
|
|
|
|
|
### Nginx
|
|
|
|
|
|
|
|
|
|
```nginx
|
|
|
|
|
```nginx {2,7,10}
|
|
|
|
|
upstream halo {
|
|
|
|
|
server 127.0.0.1:8090;
|
|
|
|
|
}
|
|
|
|
@ -159,61 +254,12 @@ server {
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Caddy 1.x
|
|
|
|
|
### Caddy 2
|
|
|
|
|
|
|
|
|
|
```txt
|
|
|
|
|
https://www.yourdomain.com {
|
|
|
|
|
gzip
|
|
|
|
|
tls your@email.com
|
|
|
|
|
proxy / localhost:8090 {
|
|
|
|
|
transparent
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Caddy 2.x
|
|
|
|
|
|
|
|
|
|
```txt
|
|
|
|
|
```txt {1,5}
|
|
|
|
|
www.yourdomain.com
|
|
|
|
|
|
|
|
|
|
encode gzip
|
|
|
|
|
|
|
|
|
|
reverse_proxy 127.0.0.1:8090
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
以上配置都可以在 <https://github.com/halo-dev/halo-common> 找到。
|
|
|
|
|
|
|
|
|
|
## 更新容器组
|
|
|
|
|
|
|
|
|
|
:::info
|
|
|
|
|
我们假设您的 Halo 服务容器是按照 [使用 Docker Compose 部署 Halo](docker-compose.md) 中的方式启动的。如有不同,请根据实际情况修改。
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
|
|
1. 停止运行中的容器组
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
cd ~/halo-next && docker-compose stop
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
2. 备份数据(重要)
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
cp -r ~/halo-next ~/halo-next.archive
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
> 需要注意的是,`halo-next.archive` 文件名不一定要根据此文档命名,这里仅仅是个示例。
|
|
|
|
|
|
|
|
|
|
3. 更新 Halo 服务
|
|
|
|
|
|
|
|
|
|
修改 `docker-compose.yaml` 中配置的镜像版本。
|
|
|
|
|
|
|
|
|
|
```yaml {3}
|
|
|
|
|
services:
|
|
|
|
|
halo_next:
|
|
|
|
|
image: halohub/halo-dev:2.0.0-rc.1
|
|
|
|
|
container_name: halo_next
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
docker-compose pull && docker-compose up -d
|
|
|
|
|
```
|
|
|
|
|