Compare commits
2 Commits
80dc8b709b
...
8c7498f0e8
| Author | SHA1 | Date |
|---|---|---|
|
|
8c7498f0e8 | |
|
|
f548778df1 |
|
|
@ -0,0 +1,146 @@
|
||||||
|
# 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**: `accupedia-media`
|
||||||
|
|
||||||
|
### Start the containers:
|
||||||
|
```bash
|
||||||
|
cd ~/acupedia/acupedia_ops
|
||||||
|
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: 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.3: 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 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.5: Validate Database Integrity
|
||||||
|
Verifies all 9 required tables exist, counts roles, permissions, modules, and published content items:
|
||||||
|
|
||||||
|
```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": 0,
|
||||||
|
"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` |
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
version: '3.8'
|
|
||||||
services:
|
services:
|
||||||
|
# ============================================================
|
||||||
|
# 1. PostgreSQL Database
|
||||||
|
# ============================================================
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:16-alpine
|
image: postgres:16-alpine
|
||||||
|
container_name: acupedia-postgres
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_DB: ${POSTGRES_DB:-acupedia_db}
|
POSTGRES_DB: ${POSTGRES_DB:-acupedia_db}
|
||||||
|
|
@ -18,8 +21,13 @@ services:
|
||||||
retries: 20
|
retries: 20
|
||||||
networks:
|
networks:
|
||||||
- acupedia-net
|
- acupedia-net
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# 2. Redis Cache
|
||||||
|
# ============================================================
|
||||||
redis:
|
redis:
|
||||||
image: redis:8.10.1-alpine
|
image: redis:7-alpine
|
||||||
|
container_name: acupedia-redis
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "${REDIS_PORT:-6379}:6379"
|
- "${REDIS_PORT:-6379}:6379"
|
||||||
|
|
@ -27,6 +35,10 @@ services:
|
||||||
- acupedia-redis-data:/data
|
- acupedia-redis-data:/data
|
||||||
networks:
|
networks:
|
||||||
- acupedia-net
|
- acupedia-net
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# 3. MinIO Object Storage
|
||||||
|
# ============================================================
|
||||||
minio:
|
minio:
|
||||||
image: minio/minio
|
image: minio/minio
|
||||||
container_name: acupedia-minio
|
container_name: acupedia-minio
|
||||||
|
|
@ -42,40 +54,118 @@ services:
|
||||||
- acupedia-minio-data:/data
|
- acupedia-minio-data:/data
|
||||||
networks:
|
networks:
|
||||||
- acupedia-net
|
- acupedia-net
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# 4. MailHog SMTP Server (Email testing)
|
||||||
|
# ============================================================
|
||||||
mailhog:
|
mailhog:
|
||||||
image: mailhog/mailhog:latest
|
image: mailhog/mailhog:latest
|
||||||
container_name: panacea-mailhog
|
container_name: acupedia-mailhog
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "1025:1025" # SMTP port
|
- "1025:1025" # SMTP port
|
||||||
- "8025:8025" # Web UI port
|
- "8025:8025" # Web UI port
|
||||||
networks:
|
networks:
|
||||||
- acupedia-net
|
- acupedia-net
|
||||||
redisinsight:
|
|
||||||
image: redis/redisinsight:latest
|
|
||||||
container_name: redis-insight
|
|
||||||
restart: always
|
|
||||||
ports:
|
|
||||||
- "5540:5540"
|
|
||||||
volumes:
|
|
||||||
- acupedia-redisinsight-data:/data
|
|
||||||
depends_on:
|
|
||||||
- redis
|
|
||||||
|
|
||||||
acupedia-content:
|
# ============================================================
|
||||||
image: gcr.io/google-containers/pause:3.9
|
# 5. Acupedia Backend API (FastAPI)
|
||||||
container_name: acupedia-content
|
# ============================================================
|
||||||
|
backend:
|
||||||
|
build:
|
||||||
|
context: ${ACUPEDIA_API_PATH:-../acupedia_api}
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
container_name: acupedia-api
|
||||||
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
postgres:
|
||||||
|
condition: service_healthy
|
||||||
|
redis:
|
||||||
|
condition: service_started
|
||||||
|
minio:
|
||||||
|
condition: service_started
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: ${POSTGRES_USER:-db_admin}
|
||||||
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-C1234spl}
|
||||||
|
POSTGRES_DB: ${POSTGRES_DB:-acupedia_db}
|
||||||
|
DATABASE_HOST: postgres
|
||||||
|
DATABASE_PORT: 5432
|
||||||
|
DATABASE_URL: postgresql+asyncpg://${POSTGRES_USER:-db_admin}:${POSTGRES_PASSWORD:-C1234spl}@postgres:5432/${POSTGRES_DB:-acupedia_db}
|
||||||
|
SYNC_DATABASE_URL: postgresql://${POSTGRES_USER:-db_admin}:${POSTGRES_PASSWORD:-C1234spl}@postgres:5432/${POSTGRES_DB:-acupedia_db}
|
||||||
|
MINIO_ENDPOINT: minio:9000
|
||||||
|
MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY:-minioadmin}
|
||||||
|
MINIO_SECRET_KEY: ${MINIO_SECRET_KEY:-minioadmin}
|
||||||
|
MINIO_SECURE: "false"
|
||||||
|
MINIO_BUCKET: ${MINIO_BUCKET_NAME:-accupedia-media}
|
||||||
|
MEDIA_PRESIGN_ENDPOINT: http://localhost:9000
|
||||||
|
MEDIA_STORAGE_ACCESS_KEY: ${MINIO_ACCESS_KEY:-minioadmin}
|
||||||
|
MEDIA_STORAGE_SECRET_KEY: ${MINIO_SECRET_KEY:-minioadmin}
|
||||||
|
MEDIA_STORAGE_BUCKET: ${MINIO_BUCKET_NAME:-accupedia-media}
|
||||||
|
MEDIA_STORAGE_REGION: us-east-1
|
||||||
|
MEDIA_URL_TTL_SECONDS: 900
|
||||||
|
REDIS_HOST: redis
|
||||||
|
REDIS_PORT: 6379
|
||||||
|
REDIS_URL: redis://redis:6379/0
|
||||||
|
CACHE_ENABLED: "true"
|
||||||
|
CACHE_REDIS_URL: redis://redis:6379/0
|
||||||
|
SMTP_HOST: mailhog
|
||||||
|
SMTP_PORT: 1025
|
||||||
|
JWT_SECRET: ${JWT_SECRET:-b4f8c9b3d0a2f4c9b3d0a2f4c9b3d0a2f4c9b3d0a2f4c9b3d0a2f4c9b3d0a2f4}
|
||||||
|
ACCESS_TOKEN_EXPIRE_MINUTES: 1440
|
||||||
|
RAZORPAY_KEY_ID: ${RAZORPAY_KEY_ID:-rzp_test_TRwmEntw35BIrL}
|
||||||
|
RAZORPAY_KEY_SECRET: ${RAZORPAY_KEY_SECRET:-vsB1RYs6J1S4EtK0u8zuZuaL}
|
||||||
|
RESEND_API_KEY: ${RESEND_API_KEY:-re_YHvSXRCz_LrQYzEYEDVwoRiAgfJRsH6ya}
|
||||||
|
ENVIRONMENT: ${ENVIRONMENT:-production}
|
||||||
|
ports:
|
||||||
|
- "${BACKEND_PORT:-8000}:8000"
|
||||||
volumes:
|
volumes:
|
||||||
- acupedia-content-data:/app/data
|
- ${CONTENT_PATH:-../acupedia_content/acupedia-content}:/app/content:ro
|
||||||
|
networks:
|
||||||
|
- acupedia-net
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# 6. Storefront Web App (Vite/React on Port 3000)
|
||||||
|
# ============================================================
|
||||||
|
store:
|
||||||
|
build:
|
||||||
|
context: ${ACUPEDIA_STORE_PATH:-../acupedia_store_ui}
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
VITE_BASE_PATH: ${VITE_STORE_BASE_PATH:-/store/}
|
||||||
|
container_name: acupedia-store
|
||||||
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
- backend
|
||||||
|
ports:
|
||||||
|
- "${STORE_PORT:-3000}:80"
|
||||||
|
networks:
|
||||||
|
- acupedia-net
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# 7. Admin Portal Web App (Vite/React on Port 3001)
|
||||||
|
# ============================================================
|
||||||
|
admin:
|
||||||
|
build:
|
||||||
|
context: ${ACUPEDIA_ADMIN_PATH:-../acupedia_web_ui}
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
VITE_BASE_PATH: ${VITE_ADMIN_BASE_PATH:-/admin/}
|
||||||
|
container_name: acupedia-admin
|
||||||
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
- backend
|
||||||
|
ports:
|
||||||
|
- "${ADMIN_PORT:-3001}:80"
|
||||||
networks:
|
networks:
|
||||||
- acupedia-net
|
- acupedia-net
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
acupedia-postgres-data:
|
acupedia-postgres-data:
|
||||||
acupedia-redis-data:
|
driver: local
|
||||||
acupedia-minio-data:
|
acupedia-minio-data:
|
||||||
acupedia-content-data:
|
driver: local
|
||||||
acupedia-redisinsight-data:
|
acupedia-redis-data:
|
||||||
|
driver: local
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
acupedia-net:
|
acupedia-net:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue