231 lines
7.2 KiB
Markdown
231 lines
7.2 KiB
Markdown
# Acupedia Platform — Manual Setup & Seeding Guide
|
|
|
|
This guide details:
|
|
1. How to back up running containers via `docker save`.
|
|
2. How to start the new clean Acupedia stack from scratch.
|
|
3. The exact manual commands to apply schemas, seed authentication, seed commerce plans, and seed clinical content without relying on `entrypoint.sh`.
|
|
|
|
---
|
|
|
|
## 1. Pre-Flight: Docker Save Backup Command (VPS)
|
|
|
|
On your VPS terminal, save the running container images directly into a standalone compressed archive:
|
|
|
|
```bash
|
|
# Set backup directory
|
|
BACKUP_DIR=~/acupedia_backups/$(date +%Y%m%d_%H%M%S)
|
|
mkdir -p $BACKUP_DIR
|
|
|
|
# 1. Database dump
|
|
docker exec -t panacea-postgres pg_dump -U postgres panaceadb > $BACKUP_DIR/panaceadb.sql
|
|
|
|
# 2. MinIO storage backup
|
|
docker run --rm -v backend_minio_data:/source -v $BACKUP_DIR:/backup alpine tar -czf /backup/minio_data.tar.gz -C /source .
|
|
|
|
# 3. Save images directly to a tar.gz archive using docker save
|
|
docker save backend-backend backend-admin backend-store | gzip > $BACKUP_DIR/acupedia_images_backup.tar.gz
|
|
|
|
echo "✅ Backup complete:"
|
|
ls -lh $BACKUP_DIR
|
|
```
|
|
|
|
*(If you ever need to restore these images on any server: `docker load < acupedia_images_backup.tar.gz`)*
|
|
|
|
---
|
|
|
|
## 2. Start the Fresh Acupedia Stack from Scratch
|
|
|
|
With the clean Acupedia naming conventions:
|
|
- **Database**: `acupedia_db`
|
|
- **User**: `db_admin` / Password: `C1234spl`
|
|
- **Volumes**: `acupedia-postgres-data`, `acupedia-minio-data`
|
|
- **MinIO Bucket**: `acupedia-media`
|
|
|
|
### Step 2.1: Generate Container Git Info Metadata (Recommended)
|
|
Before building, run the script to capture the branch and commit of `api`, `store`, and `admin`:
|
|
|
|
```bash
|
|
cd ~/acupedia/acupedia_ops
|
|
./scripts/generate-git-info.sh
|
|
```
|
|
|
|
### Step 2.2: Start the Containers
|
|
```bash
|
|
docker compose -f docker-compose.dev.yml up -d --build
|
|
```
|
|
|
|
---
|
|
|
|
## 3. Manual Step-by-Step Setup & Seeding Commands
|
|
|
|
Run these commands one by one from `~/acupedia/acupedia_ops`:
|
|
|
|
### Step 3.1: Apply the Database Schema (DDL)
|
|
Applies the four schemas (`auth`, `content`, `commerce`, `platform`), tables, indexes, and triggers:
|
|
|
|
```bash
|
|
docker compose -f docker-compose.dev.yml exec backend \
|
|
psql postgresql://db_admin:C1234spl@postgres:5432/acupedia_db -f /app/schema/accupedia_db_v5.sql
|
|
```
|
|
|
|
---
|
|
|
|
### Step 3.2: Run Alembic Migrations (Module Builder & Dynamic Content)
|
|
Stamps the baseline DDL (schema v5 includes migrations up to `0003`) and applies new migrations (such as Module Builder tables `content.builder_modules`, `content.builder_categories`, etc.):
|
|
|
|
```bash
|
|
docker compose -f docker-compose.dev.yml exec backend \
|
|
alembic stamp 0003_monthly_invoice_seq
|
|
|
|
docker compose -f docker-compose.dev.yml exec backend \
|
|
alembic upgrade head
|
|
```
|
|
|
|
---
|
|
|
|
### Step 3.3: Seed Authentication & Super Admin User
|
|
Seeds default roles (`super_admin`, `admin`, `finance_admin`, `practitioner`), permissions, and creates the super admin account:
|
|
|
|
```bash
|
|
docker compose -f docker-compose.dev.yml exec -e ACCUPEDIA_BOOTSTRAP_ADMIN_PASSWORD="Admin@12345" backend \
|
|
acupedia-bootstrap auth \
|
|
--bootstrap-admin-email "admin@acupedia.com" \
|
|
--bootstrap-admin-name "Acupedia Admin"
|
|
```
|
|
|
|
---
|
|
|
|
### Step 3.4: Seed Content & Modules
|
|
Reads the mounted `/app/content` folder, parses templates, and seeds and publishes all 16 clinical modules (`m0001` through `m0042`):
|
|
|
|
```bash
|
|
docker compose -f docker-compose.dev.yml exec backend \
|
|
acupedia-bootstrap content \
|
|
--publish-content \
|
|
--config /app/content/config.json \
|
|
--modules-root /app/content
|
|
```
|
|
|
|
---
|
|
|
|
### Step 3.4: Seed Clinical Media Assets (Images to MinIO)
|
|
Seeds all 787 anatomical images, channel pathways, and charts across the 4 visual modules into MinIO object storage (`acupedia-media` bucket) and links them to their respective content items in PostgreSQL:
|
|
|
|
**Option A (Recommended — Automated 1-line loop for all 4 modules):**
|
|
```bash
|
|
for m in m0001-acupuncture-points m0002-ear-acupuncture m0003-scalp-acupuncture m0031-nutrition; do
|
|
docker compose -f docker-compose.dev.yml exec backend \
|
|
acupedia-bootstrap media \
|
|
--manifest /app/content/$m/media.json \
|
|
--media-root /app/content/$m
|
|
done
|
|
```
|
|
|
|
**Option B (Run module-by-module individually):**
|
|
```bash
|
|
# 1. Acupuncture Points (418 images — acupoints, channels, and extraordinary vessels like Chong Mai)
|
|
docker compose -f docker-compose.dev.yml exec backend \
|
|
acupedia-bootstrap media \
|
|
--manifest /app/content/m0001-acupuncture-points/media.json \
|
|
--media-root /app/content/m0001-acupuncture-points
|
|
|
|
# 2. Ear Acupuncture (336 images — ear reflexology points)
|
|
docker compose -f docker-compose.dev.yml exec backend \
|
|
acupedia-bootstrap media \
|
|
--manifest /app/content/m0002-ear-acupuncture/media.json \
|
|
--media-root /app/content/m0002-ear-acupuncture
|
|
|
|
# 3. Scalp Acupuncture (18 images — scalp zones)
|
|
docker compose -f docker-compose.dev.yml exec backend \
|
|
acupedia-bootstrap media \
|
|
--manifest /app/content/m0003-scalp-acupuncture/media.json \
|
|
--media-root /app/content/m0003-scalp-acupuncture
|
|
|
|
# 4. Nutrition (15 images — dietary reference charts)
|
|
docker compose -f docker-compose.dev.yml exec backend \
|
|
acupedia-bootstrap media \
|
|
--manifest /app/content/m0031-nutrition/media.json \
|
|
--media-root /app/content/m0031-nutrition
|
|
```
|
|
|
|
---
|
|
|
|
### Step 3.5: Seed Commerce Plans
|
|
Seeds subscription plans, billing periods, pricing, and links them to the seeded modules from `/app/content/plans.json`:
|
|
|
|
```bash
|
|
docker compose -f docker-compose.dev.yml exec backend \
|
|
acupedia-bootstrap commerce --plans /app/content/plans.json
|
|
```
|
|
|
|
---
|
|
|
|
### Step 3.6: Validate Database Integrity
|
|
Verifies all 9 required tables exist, counts roles, permissions, modules, published content items, and seeded media assets:
|
|
|
|
```bash
|
|
docker compose -f docker-compose.dev.yml exec backend \
|
|
acupedia-bootstrap validate
|
|
```
|
|
|
|
Expected output:
|
|
```json
|
|
{
|
|
"command": "validate",
|
|
"status": "success",
|
|
"steps": [
|
|
{
|
|
"name": "validate",
|
|
"status": "success",
|
|
"details": {
|
|
"required_tables": 9,
|
|
"missing_table_count": 0,
|
|
"role_count": 4,
|
|
"permission_count": 6,
|
|
"module_count": 16,
|
|
"content_count": 2476,
|
|
"media_asset_count": 787,
|
|
"access_plan_count": 2,
|
|
"missing_tables": []
|
|
}
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## 4. Verification
|
|
|
|
After running the manual steps above, test your endpoints:
|
|
|
|
| Service | Port | Test URL |
|
|
| :--- | :---: | :--- |
|
|
| **Backend Swagger API** | `8000` | `http://<IP_OR_DOMAIN>:8000/docs` |
|
|
| **Storefront Web App** | `3000` | `http://<IP_OR_DOMAIN>:3000/store/` |
|
|
| **Admin Portal** | `3001` | `http://<IP_OR_DOMAIN>:3001/admin/` |
|
|
| **MinIO Console** | `9001` | `http://<IP_OR_DOMAIN>:9001` (`minioadmin` / `minioadmin`) |
|
|
| **MailHog UI** | `8025` | `http://<IP_OR_DOMAIN>:8025` |
|
|
|
|
### Git Identity Verification (Inspect Container Branch & Commit)
|
|
|
|
To verify which branch and commit are running inside each container:
|
|
|
|
```bash
|
|
# 1. API Backend
|
|
docker compose -f docker-compose.dev.yml exec backend cat /app/.git_api_info
|
|
|
|
# 2. Storefront
|
|
docker compose -f docker-compose.dev.yml exec store cat /app/.git_store_info
|
|
|
|
# 3. Admin Portal
|
|
docker compose -f docker-compose.dev.yml exec admin cat /app/.git_admin_info
|
|
```
|
|
|
|
Example output:
|
|
```text
|
|
Branch: main
|
|
Commit: 29279bfd72a6fa296d1aa05a825bd88ca1f36c91
|
|
```
|
|
|