acupedia-ops/docs/WINDOWS_QA_SETUP_GUIDE.md

10 KiB

Acupedia Platform — Windows QA Setup & Deployment Guide

This guide details the complete, one-time setup and regular deployment workflow for the Windows QA Machine (Desktop\AcuPedia) using the dedicated QA domain: qa.acupedia.in.

In this model:

  • No source code is shared or built on the QA machine.
  • All Docker container images are built on the Linux dev machine, exported to a compressed archive (.tar.gz), and transferred alongside a PostgreSQL database dump (backup.sql), the QA Nginx configuration (acupedia.qa.conf), and Let's Encrypt SSL certificates for qa.acupedia.in.
  • Production (acupedia.in) and QA (qa.acupedia.in) environments remain 100% decoupled.

📋 Table of Contents

  1. Overview & Prerequisites
  2. DNS Setup: Adding the A Record for qa.acupedia.in
  3. Generating Let's Encrypt SSL Certificates for qa.acupedia.in
  4. What to Prepare on Linux Dev Machine (Packaging)
  5. Target Directory Structure on Windows QA (Desktop\AcuPedia)
  6. Updating Nginx Configuration (acupedia.qa.conf)
  7. Step-by-Step QA Machine Setup (PowerShell)
  8. SSL Certificate Auto-Renewal & Scheduled Task
  9. Accessing the QA Environment via HTTPS
  10. Quick Update Runbook (Future Deployments)

1. Overview & Prerequisites

Prerequisites on Windows QA Machine:

  • OS: Windows 10/11 Pro or Enterprise (64-bit)
  • Docker Desktop: Installed and running with WSL 2 backend enabled.
  • PowerShell: Run as Administrator for initial setup.
  • Target Folder: Desktop\AcuPedia (i.e. $HOME\Desktop\AcuPedia)

2. DNS Setup: Adding the A Record for qa.acupedia.in

In your DNS provider dashboard (Cloudflare, GoDaddy, Route53, Namecheap, etc.), add the DNS record pointing to your QA environment IP:

Type Name / Host Value / Target TTL
A qa <QA_MACHINE_PUBLIC_OR_ROUTER_IP> Auto / 300s
A api-qa (optional) <QA_MACHINE_PUBLIC_OR_ROUTER_IP> Auto / 300s

[!TIP] If the QA machine is inside an office LAN without a public IP: You can point qa.acupedia.in to the QA machine's local IP (e.g., 192.168.1.50) in your office router DNS or client hosts files: 192.168.1.50 qa.acupedia.in api-qa.acupedia.in


3. Generating Let's Encrypt SSL Certificates for qa.acupedia.in

Once the DNS record is pointing to the machine:

Run on your Linux machine:

sudo certbot certonly --standalone \
  -d qa.acupedia.in \
  -d api-qa.acupedia.in

The certificates will be generated at /etc/letsencrypt/live/qa.acupedia.in/:

  • fullchain.pem
  • privkey.pem
  • /etc/letsencrypt/options-ssl-nginx.conf
  • /etc/letsencrypt/ssl-dhparams.pem

Option B: Generate using Docker Certbot on the Windows QA Machine

If ports 80 and 443 are forwarded to the Windows machine, run in PowerShell:

docker run -it --rm -p 80:80 `
  -v ${PWD}\certs:/etc/letsencrypt `
  certbot/certbot certonly --standalone `
  -d qa.acupedia.in -d api-qa.acupedia.in

4. What to Prepare on Linux Dev Machine (Packaging)

Build and export the deployment bundle on Linux before transferring to QA:

Step 4.1: Generate Git Info & Build Images

cd ~/acupedia/acupedia_ops
./scripts/generate-git-info.sh
docker compose -f docker-compose.dev.yml build backend store admin

Step 4.2: Export Docker Images to .tar.gz

docker save \
  acupedia-ops-backend:latest \
  acupedia-ops-store:latest \
  acupedia-ops-admin:latest | gzip > ~/acupedia_images.tar.gz

Step 4.3: Export Seeded Database Dump (backup.sql)

docker exec -t acupedia-postgres pg_dump -U db_admin -d acupedia_db > ~/backup.sql

Step 4.4: Gather Config & Certificates

  • QA Nginx configuration: config/nginx/acupedia.qa.conf
  • Let's Encrypt certificates for qa.acupedia.in:
    • fullchain.pem
    • privkey.pem
    • options-ssl-nginx.conf
    • ssl-dhparams.pem

5. Target Directory Structure on Windows QA (Desktop\AcuPedia)

Place all transferred files on the Windows QA machine in this exact structure:

Desktop\AcuPedia\
├── docker-compose.dev.yml        # Compose file
├── .env                          # Environment variables
├── backup.sql                    # PostgreSQL database dump
├── acupedia_images.tar.gz        # Exported Docker images archive
├── config\
│   └── nginx\
│       └── acupedia.qa.conf      # QA Nginx gateway configuration (qa.acupedia.in)
└── certs\
    ├── options-ssl-nginx.conf    # Let's Encrypt SSL options
    ├── ssl-dhparams.pem          # Diffie-Hellman parameters
    └── live\
        └── qa.acupedia.in\
            ├── fullchain.pem     # SSL fullchain certificate
            └── privkey.pem       # SSL private key

6. Updating Nginx Configuration (acupedia.qa.conf)

Step 6.1: Verify the Compose File Volume Mount

In Desktop\AcuPedia\docker-compose.dev.yml, ensure the nginx service mounts the new acupedia.qa.conf and certificate directory:

  # 8. Central Nginx Reverse Proxy (QA Gateway)
  nginx:
    image: nginx:alpine
    container_name: acupedia-nginx
    restart: unless-stopped
    depends_on:
      - backend
      - store
      - admin
      - minio
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./config/nginx/acupedia.qa.conf:/etc/nginx/conf.d/default.conf:ro
      - ./certs:/etc/letsencrypt:ro
      - ./certbot:/var/www/certbot
    networks:
      - acupedia-net

Step 6.2: What acupedia.qa.conf Routes

The QA Nginx configuration handles all routes under qa.acupedia.in:

  • https://qa.acupedia.in/ \rightarrow Storefront Frontend (store:80)
  • https://qa.acupedia.in/admin \rightarrow Admin Portal (admin:80)
  • https://qa.acupedia.in/api/ \rightarrow Backend FastAPI (backend:8000)
  • https://qa.acupedia.in/docs \rightarrow FastAPI Swagger UI (backend:8000/docs)
  • https://qa.acupedia.in/acupedia-media/ \rightarrow MinIO S3 Presigned Media (minio:9000)
  • (Optional) https://api-qa.acupedia.in/ \rightarrow Dedicated API Subdomain (backend:8000)

7. Step-by-Step QA Machine Setup (PowerShell)

Open PowerShell as Administrator and navigate to the directory:

cd $HOME\Desktop\AcuPedia

Step 7.1: Load Docker Images

docker load -i .\acupedia_images.tar.gz

Verify with: docker images — acupedia-ops-backend, acupedia-ops-store, and acupedia-ops-admin should be listed.

Step 7.2: Start Database & Storage Containers

docker compose -f docker-compose.dev.yml up -d postgres redis minio mailhog

Wait 10 seconds for PostgreSQL to report healthy:

docker ps

Step 7.3: Restore Database Dump

Get-Content .\backup.sql | docker exec -i acupedia-postgres psql -U db_admin -d acupedia_db

Step 7.4: Start All Services (Including QA Nginx)

docker compose -f docker-compose.dev.yml up -d

Step 7.5: Verify Container Health & Embedded Git Metadata

# 1. Check all container statuses
docker ps

# 2. Inspect embedded Git branch & commit in each container
docker exec acupedia-api cat /app/.git_api_info
docker exec acupedia-store cat /app/.git_store_info
docker exec acupedia-admin cat /app/.git_admin_info

# 3. Check Nginx logs to ensure SSL loaded with 0 errors
docker logs acupedia-nginx --tail 20

8. SSL Certificate Auto-Renewal & Scheduled Task

Certificates from Let's Encrypt are valid for 90 days.

Method 1: Automated Renewal via Windows Task Scheduler (If Publicly Accessible)

Run once in Administrator PowerShell:

$Action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-Command `"cd `$HOME\Desktop\AcuPedia; docker run --rm -v `$PWD\certs:/etc/letsencrypt -v `$PWD\certbot:/var/www/certbot certbot/certbot renew --webroot -w /var/www/certbot; docker restart acupedia-nginx`""
$Trigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Sunday -At 3am
Register-ScheduledTask -TaskName "AcupediaQACertbotRenewal" -Action $Action -Trigger $Trigger -User "SYSTEM"

Method 2: Manual Certificate Update (If Behind Office Router)

When certificates renew on your Linux server, simply replace the two files on Windows:

  • Desktop\AcuPedia\certs\live\qa.acupedia.in\fullchain.pem
  • Desktop\AcuPedia\certs\live\qa.acupedia.in\privkey.pem

Then reload Nginx:

docker restart acupedia-nginx

9. Accessing the QA Environment via HTTPS

Once running, any developer, tester, or mobile device can access the environment over secure HTTPS:

Application URL Description
Storefront Web App https://qa.acupedia.in/ Customer storefront (React/Vite)
Admin Portal https://qa.acupedia.in/admin/ Management console
Backend Swagger Docs https://qa.acupedia.in/docs Interactive API documentation
Backend API Root https://qa.acupedia.in/api/ REST API endpoints
Dedicated API (Optional) https://api-qa.acupedia.in/ Dedicated subdomain API

10. Quick Update Runbook (Future Deployments)

When a new update or bugfix is ready for QA, follow this 3-step routine:

On Linux (Dev Machine):

./scripts/generate-git-info.sh
docker compose -f docker-compose.dev.yml build backend store admin
docker save acupedia-ops-backend:latest acupedia-ops-store:latest acupedia-ops-admin:latest | gzip > acupedia_images.tar.gz
# Send acupedia_images.tar.gz to QA machine

On Windows QA (PowerShell):

cd $HOME\Desktop\AcuPedia
docker load -i .\acupedia_images.tar.gz
docker compose -f docker-compose.dev.yml up -d --no-build backend store admin
docker ps

The QA environment is now updated, and running docker exec acupedia-api cat /app/.git_api_info confirms the exact new Git commit!