diff --git a/compose/README.md b/compose/README.md new file mode 100644 index 0000000..9d58786 --- /dev/null +++ b/compose/README.md @@ -0,0 +1,57 @@ +# Halo 前后端服务的 Docker Compose + +通过 Docker Compose 的方式启动 Halo 前后端服务快速查看插件效果。 + +## 开发指引 + +### 环境要求 + +- OpenJDK 17 +- NodeJS 16+ +- pnpm 7+ +- Docker +- Docker Compose + +### 编译插件 + +下载前端依赖: + +```bash +cd ./plugin-template + +./gradlew.bat pnpmInstall + +# or macOS/Linux + +./gradlew pnpmInstall +``` + +构建: + +```bash +./gradlew.bat build + +# or macOS/Linux + +./gradlew build +``` + +### 启动 Halo + +```bash +cd plugin-template/compose +docker-compose up -d +docker-compose ps +``` + +### 访问后台 + +在浏览器中访问 https://localhost/admin 即可,登录用户名和密码为当前目录中 `application-dev.yaml` 配置中的 `super-admin-username` +和 `super-admin-password`。 + +然后在左侧菜单中选择 `插件`,即可查看所有插件的状态。 + +### 开发 + +修改前端代码或者后端代码,然后运行 `./gradlew.bat build` 或者 `./gradlew build`(macOS/Linux)即可构建插件,无需重启 +Halo。但修改配置文件后需要 build 插件以及重启 Halo。 \ No newline at end of file diff --git a/compose/application.yaml b/compose/application.yaml new file mode 100644 index 0000000..451b8cb --- /dev/null +++ b/compose/application.yaml @@ -0,0 +1,40 @@ +server: + port: 8090 +spring: + profiles: + active: dev +halo: + # external-url: https://next.ryanc.cc/ + security: + initializer: + super-admin-username: admin + super-admin-password: P@88w0rd + oauth2: + jwt: + jwsAlgorithm: rs512 + public-key-location: classpath:app.pub + private-key-location: classpath:app.key + plugin: + runtime-mode: development # development, deployment + classes-directories: + - "build/classes" + - "build/resources" + lib-directories: + - "libs" + fixedPluginPath: + - "/plugin" +springdoc: + api-docs: + enabled: true + swagger-ui: + enabled: true + show-login-endpoint: false + show-actuator: false + use-management-port: false +management: + endpoints: + web: + exposure: + include: health,info,metrics,startup,shutdown + server: + port: 8090 \ No newline at end of file diff --git a/compose/docker-compose.yaml b/compose/docker-compose.yaml new file mode 100644 index 0000000..8bb9b9c --- /dev/null +++ b/compose/docker-compose.yaml @@ -0,0 +1,22 @@ +services: + halo: + image: halohub/halo-dev:next + ports: + - 8090:8090 + environment: + - SPRING_CONFIG_ADDITIONAL_LOCATION=optional:file:/etc/config/ + volumes: + - ./application.yaml:/etc/config/application.yaml + - ../:/plugin + networks: + - halo + halo-admin: + image: halohub/admin-dev:next + ports: + - 80:80 + volumes: + - ./halo.conf:/etc/nginx/conf.d/default.conf + networks: + - halo +networks: + halo: {} diff --git a/compose/halo.conf b/compose/halo.conf new file mode 100644 index 0000000..0eb5c0f --- /dev/null +++ b/compose/halo.conf @@ -0,0 +1,25 @@ +server { + listen 80; + listen [::]:80; + server_name localhost; + + #access_log /var/log/nginx/host.access.log main; + + location / { + proxy_pass http://halo:8090; + } + + location /admin { + alias /usr/share/nginx/html; + index index.html index.htm; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} \ No newline at end of file