added new config file for qa setup and manual for that
This commit is contained in:
parent
a751488d9d
commit
bb1f6c5ada
|
|
@ -0,0 +1,178 @@
|
|||
# ==============================================================================
|
||||
# Acupedia Platform — QA Containerized Nginx Gateway Configuration
|
||||
# File: config/nginx/acupedia.qa.conf
|
||||
#
|
||||
# Domain: qa.acupedia.in (and optional api-qa.acupedia.in)
|
||||
#
|
||||
# Container Upstreams:
|
||||
# - Backend API -> backend:8000
|
||||
# - Storefront -> store:80
|
||||
# - Admin Suite -> admin:80
|
||||
# - MinIO S3 -> minio:9000
|
||||
# ==============================================================================
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Upstream Definitions (Docker Internal DNS on acupedia-net)
|
||||
# ------------------------------------------------------------------------------
|
||||
upstream backend_api {
|
||||
server backend:8000;
|
||||
keepalive 32;
|
||||
}
|
||||
|
||||
upstream store_app {
|
||||
server store:80;
|
||||
keepalive 16;
|
||||
}
|
||||
|
||||
upstream admin_app {
|
||||
server admin:80;
|
||||
keepalive 16;
|
||||
}
|
||||
|
||||
upstream minio_storage {
|
||||
server minio:9000;
|
||||
keepalive 32;
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# 1. HTTP to HTTPS Global Redirect (Ports 80 -> 443)
|
||||
# ==============================================================================
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name qa.acupedia.in api-qa.acupedia.in;
|
||||
|
||||
# Let's Encrypt ACME challenge (used for certbot renewal)
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /var/www/certbot;
|
||||
}
|
||||
|
||||
# Redirect all HTTP requests to HTTPS
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# 2. QA Dedicated API Subdomain (api-qa.acupedia.in) - Optional
|
||||
# ==============================================================================
|
||||
server {
|
||||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
server_name api-qa.acupedia.in;
|
||||
|
||||
# SSL Certificates (Mounted from host /etc/letsencrypt)
|
||||
ssl_certificate /etc/letsencrypt/live/qa.acupedia.in/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/qa.acupedia.in/privkey.pem;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_prefer_server_ciphers off;
|
||||
|
||||
client_max_body_size 50M;
|
||||
|
||||
# Common Proxy Headers
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 120s;
|
||||
proxy_read_timeout 120s;
|
||||
|
||||
# Mobile App redirects
|
||||
location /cart {
|
||||
return 301 https://qa.acupedia.in$request_uri;
|
||||
}
|
||||
|
||||
location /checkout {
|
||||
return 301 https://qa.acupedia.in$request_uri;
|
||||
}
|
||||
|
||||
# MinIO S3 Presigned Media Proxy (/acupedia-media/)
|
||||
location /acupedia-media/ {
|
||||
proxy_pass http://minio_storage;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
# FastAPI Swagger Docs & OpenAPI Schema
|
||||
location /docs {
|
||||
proxy_pass http://backend_api/docs;
|
||||
}
|
||||
|
||||
location /openapi.json {
|
||||
proxy_pass http://backend_api/openapi.json;
|
||||
}
|
||||
|
||||
# Route all API traffic to FastAPI Backend on port 8000
|
||||
location / {
|
||||
proxy_pass http://backend_api;
|
||||
}
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# 3. QA Main Domain: Storefront (/), Admin (/admin), API (/api/), Docs (/docs)
|
||||
# ==============================================================================
|
||||
server {
|
||||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
server_name qa.acupedia.in;
|
||||
|
||||
# SSL Certificates (Mounted from host /etc/letsencrypt)
|
||||
ssl_certificate /etc/letsencrypt/live/qa.acupedia.in/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/qa.acupedia.in/privkey.pem;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_prefer_server_ciphers off;
|
||||
|
||||
client_max_body_size 50M;
|
||||
|
||||
# Common Proxy Headers
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 120s;
|
||||
proxy_read_timeout 120s;
|
||||
|
||||
# Admin Panel (/admin)
|
||||
location /admin {
|
||||
proxy_pass http://admin_app;
|
||||
}
|
||||
|
||||
# Backend API access via same-origin (qa.acupedia.in/api/ -> avoids CORS)
|
||||
location /api/ {
|
||||
proxy_pass http://backend_api/api/;
|
||||
}
|
||||
|
||||
# FastAPI Swagger Docs (/docs)
|
||||
location /docs {
|
||||
proxy_pass http://backend_api/docs;
|
||||
}
|
||||
|
||||
location /openapi.json {
|
||||
proxy_pass http://backend_api/openapi.json;
|
||||
}
|
||||
|
||||
# MinIO S3 Presigned Media Proxy (/acupedia-media/)
|
||||
location /acupedia-media/ {
|
||||
proxy_pass http://minio_storage;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
# Storefront Customer Web App (/)
|
||||
location / {
|
||||
proxy_pass http://store_app;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,282 @@
|
|||
# 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](#1-overview--prerequisites)
|
||||
2. [DNS Setup: Adding the A Record for `qa.acupedia.in`](#2-dns-setup-adding-the-a-record-for-qaacupediain)
|
||||
3. [Generating Let's Encrypt SSL Certificates for `qa.acupedia.in`](#3-generating-lets-encrypt-ssl-certificates-for-qaacupediain)
|
||||
4. [What to Prepare on Linux Dev Machine (Packaging)](#4-what-to-prepare-on-linux-dev-machine-packaging)
|
||||
5. [Target Directory Structure on Windows QA (`Desktop\AcuPedia`)](#5-target-directory-structure-on-windows-qa-desktopacupedia)
|
||||
6. [Updating Nginx Configuration (`acupedia.qa.conf`)](#6-updating-nginx-configuration-acupediaqaconf)
|
||||
7. [Step-by-Step QA Machine Setup (PowerShell)](#7-step-by-step-qa-machine-setup-powershell)
|
||||
8. [SSL Certificate Auto-Renewal & Scheduled Task](#8-ssl-certificate-auto-renewal--scheduled-task)
|
||||
9. [Accessing the QA Environment via HTTPS](#9-accessing-the-qa-environment-via-https)
|
||||
10. [Quick Update Runbook (Future Deployments)](#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:
|
||||
|
||||
### Option A: Generate via Certbot on Linux Dev/VPS Machine (Recommended)
|
||||
Run on your Linux machine:
|
||||
```bash
|
||||
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:
|
||||
```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
|
||||
```bash
|
||||
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`
|
||||
```bash
|
||||
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`)
|
||||
```bash
|
||||
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:
|
||||
|
||||
```text
|
||||
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:
|
||||
|
||||
```yaml
|
||||
# 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:
|
||||
|
||||
```powershell
|
||||
cd $HOME\Desktop\AcuPedia
|
||||
```
|
||||
|
||||
### Step 7.1: Load Docker Images
|
||||
```powershell
|
||||
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
|
||||
```powershell
|
||||
docker compose -f docker-compose.dev.yml up -d postgres redis minio mailhog
|
||||
```
|
||||
Wait 10 seconds for PostgreSQL to report healthy:
|
||||
```powershell
|
||||
docker ps
|
||||
```
|
||||
|
||||
### Step 7.3: Restore Database Dump
|
||||
```powershell
|
||||
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)
|
||||
```powershell
|
||||
docker compose -f docker-compose.dev.yml up -d
|
||||
```
|
||||
|
||||
### Step 7.5: Verify Container Health & Embedded Git Metadata
|
||||
```powershell
|
||||
# 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:
|
||||
```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:
|
||||
```powershell
|
||||
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):
|
||||
```bash
|
||||
./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):
|
||||
```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!
|
||||
Loading…
Reference in New Issue