99 lines
2.4 KiB
Markdown
99 lines
2.4 KiB
Markdown
# Chatapp testbox
|
|
|
|
Single-node test environment for chatapp Java services, Go API, cron worker,
|
|
and local infra.
|
|
|
|
Public API entry:
|
|
|
|
```text
|
|
https://jvapi-test.haiyihy.com
|
|
```
|
|
|
|
## What runs here
|
|
|
|
- MySQL 8.0
|
|
- Redis 7
|
|
- MongoDB 7
|
|
- Nacos standalone, namespace `RedCircleServiceTest`
|
|
- RocketMQ namesrv/broker/proxy
|
|
- Java: auth, gateway, external, console, other, live, wallet, order
|
|
- Go: chatapp3-golang API
|
|
- Cron: chatapp-cron week-star worker
|
|
- Admin: chatapp3-admin at `https://yumi-test-admin.haiyihy.com`
|
|
- Caddy for HTTPS reverse proxy to gateway
|
|
|
|
## First deployment
|
|
|
|
Make sure SSH works first:
|
|
|
|
```bash
|
|
ssh root@43.165.195.39 'hostname'
|
|
```
|
|
|
|
Then trigger a git-based deploy:
|
|
|
|
```bash
|
|
cd /Users/hy/Documents/haiyi/hy-app-monitor
|
|
bash testbox/scripts/deploy-from-git.sh root@43.165.195.39
|
|
```
|
|
|
|
The script only SSHes to the testbox. The server pulls these git repositories,
|
|
installs Docker on the testbox, starts infra, imports Nacos configs, applies
|
|
MySQL baseline files, builds images, and starts apps:
|
|
|
|
```text
|
|
git@gitea.haiyihy.com:hy/hy-app-monitor.git
|
|
git@gitea.haiyihy.com:hy/chatapp3-java.git
|
|
git@gitea.haiyihy.com:hy/chatapp3-golang.git
|
|
git@gitea.haiyihy.com:hy/chatapp-cron.git
|
|
git@gitea.haiyihy.com:hy/chatapp3-admin.git
|
|
```
|
|
|
|
After first deployment, you can run the deploy directly on the server:
|
|
|
|
```bash
|
|
ssh root@43.165.195.39 'bash /opt/chatapp-test/scripts/deploy-from-git-remote.sh'
|
|
```
|
|
|
|
The runtime `.env` stays on the server at `/opt/chatapp-test/.env`; git deploys
|
|
do not overwrite it.
|
|
|
|
## MySQL baseline
|
|
|
|
Java services need real schema and base config rows. Put sanitized SQL files in:
|
|
|
|
```text
|
|
testbox/mysql/baseline/
|
|
```
|
|
|
|
They are applied in lexical order. Recommended:
|
|
|
|
```text
|
|
10-schema.sql
|
|
20-base-data.sql
|
|
```
|
|
|
|
The deploy script then applies Go migrations from `chatapp3-golang/migrations`
|
|
and Java incremental SQL from `chatapp3-java/sql`.
|
|
|
|
## Runtime commands on the server
|
|
|
|
```bash
|
|
cd /opt/chatapp-test
|
|
docker compose --env-file .env -f docker-compose.infra.yml -f docker-compose.apps.yml ps
|
|
docker compose --env-file .env -f docker-compose.infra.yml -f docker-compose.apps.yml logs -f gateway
|
|
docker compose --env-file .env -f docker-compose.infra.yml -f docker-compose.apps.yml restart other
|
|
```
|
|
|
|
Local-only infra ports on the server:
|
|
|
|
```text
|
|
127.0.0.1:3306 MySQL
|
|
127.0.0.1:6379 Redis
|
|
127.0.0.1:27017 Mongo
|
|
127.0.0.1:8848 Nacos
|
|
127.0.0.1:8081 RocketMQ proxy
|
|
```
|
|
|
|
Only `80/443` are intended to be public.
|