Compare commits
7 Commits
redis-issu
...
main
| Author | SHA1 | Date |
|---|---|---|
|
|
4683f39e60 | |
|
|
76289bef57 | |
|
|
6504fd3e68 | |
|
|
2ffc763c40 | |
|
|
808183637a | |
|
|
cf7661094d | |
|
|
bb1f6c5ada |
|
|
@ -0,0 +1,178 @@
|
||||||
|
# ==============================================================================
|
||||||
|
# Acupedia Platform — QA Containerized Nginx Gateway Configuration
|
||||||
|
# File: config/nginx/acupedia.qa.conf
|
||||||
|
#
|
||||||
|
# Domain: qa.acupedia.in (and optional qa-api.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 qa-api.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 (qa-api.acupedia.in) - Optional
|
||||||
|
# ==============================================================================
|
||||||
|
server {
|
||||||
|
listen 443 ssl;
|
||||||
|
listen [::]:443 ssl;
|
||||||
|
server_name qa-api.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -11,7 +11,8 @@ services:
|
||||||
POSTGRES_USER: ${POSTGRES_USER:-db_admin}
|
POSTGRES_USER: ${POSTGRES_USER:-db_admin}
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-C1234spl}
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-C1234spl}
|
||||||
ports:
|
ports:
|
||||||
- "${POSTGRES_PORT:-5432}:5432"
|
# Bound strictly to 127.0.0.1 (Localhost only - safe from other LAN/remote PCs)
|
||||||
|
- "127.0.0.1:${POSTGRES_PORT:-5432}:5432"
|
||||||
volumes:
|
volumes:
|
||||||
- acupedia-postgres-data:/var/lib/postgresql/data
|
- acupedia-postgres-data:/var/lib/postgresql/data
|
||||||
healthcheck:
|
healthcheck:
|
||||||
|
|
@ -31,6 +32,7 @@ services:
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
command: redis-server --requirepass "${REDIS_PASSWORD:-AcupediaSecureRedis2026!#}"
|
command: redis-server --requirepass "${REDIS_PASSWORD:-AcupediaSecureRedis2026!#}"
|
||||||
ports:
|
ports:
|
||||||
|
# Bound strictly to 127.0.0.1
|
||||||
- "127.0.0.1:${REDIS_PORT:-6379}:6379"
|
- "127.0.0.1:${REDIS_PORT:-6379}:6379"
|
||||||
volumes:
|
volumes:
|
||||||
- acupedia-redis-data:/data
|
- acupedia-redis-data:/data
|
||||||
|
|
@ -49,8 +51,9 @@ services:
|
||||||
MINIO_ROOT_USER: ${MINIO_ACCESS_KEY:-minioadmin}
|
MINIO_ROOT_USER: ${MINIO_ACCESS_KEY:-minioadmin}
|
||||||
MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY:-minioadmin}
|
MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY:-minioadmin}
|
||||||
ports:
|
ports:
|
||||||
- "${MINIO_PORT:-9000}:9000"
|
# Bound strictly to 127.0.0.1 - Nginx proxies public /acupedia-media/ requests
|
||||||
- "${MINIO_CONSOLE_PORT:-9001}:9001"
|
- "127.0.0.1:${MINIO_PORT:-9000}:9000"
|
||||||
|
- "127.0.0.1:${MINIO_CONSOLE_PORT:-9001}:9001"
|
||||||
volumes:
|
volumes:
|
||||||
- acupedia-minio-data:/data
|
- acupedia-minio-data:/data
|
||||||
networks:
|
networks:
|
||||||
|
|
@ -64,8 +67,9 @@ services:
|
||||||
container_name: acupedia-mailhog
|
container_name: acupedia-mailhog
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "1025:1025" # SMTP port
|
# Bound strictly to 127.0.0.1 so email UI is not exposed publicly
|
||||||
- "8025:8025" # Web UI port
|
- "127.0.0.1:1025:1025" # SMTP port
|
||||||
|
- "127.0.0.1:8025:8025" # Web UI port
|
||||||
networks:
|
networks:
|
||||||
- acupedia-net
|
- acupedia-net
|
||||||
|
|
||||||
|
|
@ -73,6 +77,7 @@ services:
|
||||||
# 5. Acupedia Backend API (FastAPI)
|
# 5. Acupedia Backend API (FastAPI)
|
||||||
# ============================================================
|
# ============================================================
|
||||||
backend:
|
backend:
|
||||||
|
image: acupedia-ops-backend:latest
|
||||||
build:
|
build:
|
||||||
context: ${ACUPEDIA_API_PATH:-../../acupedia-api}
|
context: ${ACUPEDIA_API_PATH:-../../acupedia-api}
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
|
@ -99,7 +104,7 @@ services:
|
||||||
MINIO_SECURE: "false"
|
MINIO_SECURE: "false"
|
||||||
MINIO_BUCKET: ${MINIO_BUCKET_NAME:-acupedia-media}
|
MINIO_BUCKET: ${MINIO_BUCKET_NAME:-acupedia-media}
|
||||||
MEDIA_STORAGE_SECURE: ${MEDIA_STORAGE_SECURE:-true}
|
MEDIA_STORAGE_SECURE: ${MEDIA_STORAGE_SECURE:-true}
|
||||||
MEDIA_PRESIGN_ENDPOINT: ${MEDIA_PRESIGN_ENDPOINT:-http://localhost:9000}
|
MEDIA_PRESIGN_ENDPOINT: ${MEDIA_PRESIGN_ENDPOINT:-https://qa.acupedia.in}
|
||||||
MEDIA_STORAGE_ACCESS_KEY: ${MINIO_ACCESS_KEY:-minioadmin}
|
MEDIA_STORAGE_ACCESS_KEY: ${MINIO_ACCESS_KEY:-minioadmin}
|
||||||
MEDIA_STORAGE_SECRET_KEY: ${MINIO_SECRET_KEY:-minioadmin}
|
MEDIA_STORAGE_SECRET_KEY: ${MINIO_SECRET_KEY:-minioadmin}
|
||||||
MEDIA_STORAGE_BUCKET: ${MINIO_BUCKET_NAME:-acupedia-media}
|
MEDIA_STORAGE_BUCKET: ${MINIO_BUCKET_NAME:-acupedia-media}
|
||||||
|
|
@ -118,9 +123,11 @@ services:
|
||||||
RAZORPAY_KEY_ID: ${RAZORPAY_KEY_ID:-rzp_test_TRwmEntw35BIrL}
|
RAZORPAY_KEY_ID: ${RAZORPAY_KEY_ID:-rzp_test_TRwmEntw35BIrL}
|
||||||
RAZORPAY_KEY_SECRET: ${RAZORPAY_KEY_SECRET:-vsB1RYs6J1S4EtK0u8zuZuaL}
|
RAZORPAY_KEY_SECRET: ${RAZORPAY_KEY_SECRET:-vsB1RYs6J1S4EtK0u8zuZuaL}
|
||||||
RESEND_API_KEY: ${RESEND_API_KEY:-re_YHvSXRCz_LrQYzEYEDVwoRiAgfJRsH6ya}
|
RESEND_API_KEY: ${RESEND_API_KEY:-re_YHvSXRCz_LrQYzEYEDVwoRiAgfJRsH6ya}
|
||||||
|
CONTENT_PREVIEW_ENABLED: ${CONTENT_PREVIEW_ENABLED:-true}
|
||||||
ENVIRONMENT: ${ENVIRONMENT:-production}
|
ENVIRONMENT: ${ENVIRONMENT:-production}
|
||||||
ports:
|
ports:
|
||||||
- "${BACKEND_PORT:-8000}:8000"
|
# Bound to localhost only (Nginx proxies all public API traffic)
|
||||||
|
- "127.0.0.1:${BACKEND_PORT:-8000}:8000"
|
||||||
volumes:
|
volumes:
|
||||||
- ${CONTENT_PATH:-../../acupedia_content/acupedia-content}:/app/content:ro
|
- ${CONTENT_PATH:-../../acupedia_content/acupedia-content}:/app/content:ro
|
||||||
networks:
|
networks:
|
||||||
|
|
@ -130,6 +137,7 @@ services:
|
||||||
# 6. Storefront Web App (Vite/React on Port 3000)
|
# 6. Storefront Web App (Vite/React on Port 3000)
|
||||||
# ============================================================
|
# ============================================================
|
||||||
store:
|
store:
|
||||||
|
image: acupedia-ops-store:latest
|
||||||
build:
|
build:
|
||||||
context: ${ACUPEDIA_STORE_PATH:-../../acupedia_store_ui}
|
context: ${ACUPEDIA_STORE_PATH:-../../acupedia_store_ui}
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
|
@ -140,7 +148,8 @@ services:
|
||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
||||||
ports:
|
ports:
|
||||||
- "${STORE_PORT:-3000}:80"
|
# Bound to localhost only (Nginx handles public traffic via qa.acupedia.in/)
|
||||||
|
- "127.0.0.1:${STORE_PORT:-3000}:80"
|
||||||
networks:
|
networks:
|
||||||
- acupedia-net
|
- acupedia-net
|
||||||
|
|
||||||
|
|
@ -148,6 +157,7 @@ services:
|
||||||
# 7. Admin Portal Web App (Vite/React on Port 3001)
|
# 7. Admin Portal Web App (Vite/React on Port 3001)
|
||||||
# ============================================================
|
# ============================================================
|
||||||
admin:
|
admin:
|
||||||
|
image: acupedia-ops-admin:latest
|
||||||
build:
|
build:
|
||||||
context: ${ACUPEDIA_ADMIN_PATH:-../../acupedia_web_ui}
|
context: ${ACUPEDIA_ADMIN_PATH:-../../acupedia_web_ui}
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
|
@ -158,12 +168,13 @@ services:
|
||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
||||||
ports:
|
ports:
|
||||||
- "${ADMIN_PORT:-3001}:80"
|
# Bound to localhost only (Nginx handles public traffic via qa.acupedia.in/admin)
|
||||||
|
- "127.0.0.1:${ADMIN_PORT:-3001}:80"
|
||||||
networks:
|
networks:
|
||||||
- acupedia-net
|
- acupedia-net
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# 8. Central Nginx Reverse Proxy (Containerized Gateway)
|
# 8. Central Nginx Reverse Proxy (QA Containerized Gateway)
|
||||||
# ============================================================
|
# ============================================================
|
||||||
nginx:
|
nginx:
|
||||||
image: nginx:alpine
|
image: nginx:alpine
|
||||||
|
|
@ -175,12 +186,13 @@ services:
|
||||||
- admin
|
- admin
|
||||||
- minio
|
- minio
|
||||||
ports:
|
ports:
|
||||||
|
# The ONLY services exposed to the network/internet
|
||||||
- "${HTTP_PORT:-80}:80"
|
- "${HTTP_PORT:-80}:80"
|
||||||
- "${HTTPS_PORT:-443}:443"
|
- "${HTTPS_PORT:-443}:443"
|
||||||
volumes:
|
volumes:
|
||||||
- ./config/nginx/acupedia.conf:/etc/nginx/conf.d/default.conf:ro
|
- ./config/nginx/acupedia.qa.conf:/etc/nginx/conf.d/default.conf:ro
|
||||||
- /etc/letsencrypt:/etc/letsencrypt:ro
|
- ${CERTS_PATH:-./certs}:/etc/letsencrypt:ro
|
||||||
- /var/www/certbot:/var/www/certbot
|
- ./certbot:/var/www/certbot
|
||||||
networks:
|
networks:
|
||||||
- acupedia-net
|
- acupedia-net
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,35 @@
|
||||||
version: '3.8'
|
|
||||||
services:
|
services:
|
||||||
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}
|
||||||
POSTGRES_USER: ${POSTGRES_USER:-db_admin}
|
POSTGRES_USER: ${POSTGRES_USER:-db_admin}
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-C1234spl}
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-C1234spl}
|
||||||
ports:
|
ports:
|
||||||
- "${POSTGRES_PORT:-5432}:5432"
|
- "127.0.0.1:${POSTGRES_PORT:-5432}:5432"
|
||||||
volumes:
|
volumes:
|
||||||
- acupedia-postgres-data:/var/lib/postgresql/data
|
- acupedia-postgres-data:/var/lib/postgresql/data
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-acupedia} -d ${POSTGRES_DB:-acupedia_db}"]
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-db_admin} -d ${POSTGRES_DB:-acupedia_db}"]
|
||||||
interval: 5s
|
interval: 5s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 20
|
retries: 20
|
||||||
networks:
|
networks:
|
||||||
- acupedia-net
|
- acupedia-net
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:8.10.1-alpine
|
image: redis:8.10.1-alpine
|
||||||
|
container_name: acupedia-redis
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "${REDIS_PORT:-6379}:6379"
|
- "127.0.0.1:${REDIS_PORT:-6379}:6379"
|
||||||
volumes:
|
volumes:
|
||||||
- acupedia-redis-data:/data
|
- acupedia-redis-data:/data
|
||||||
networks:
|
networks:
|
||||||
- acupedia-net
|
- acupedia-net
|
||||||
|
|
||||||
minio:
|
minio:
|
||||||
image: minio/minio
|
image: minio/minio
|
||||||
container_name: acupedia-minio
|
container_name: acupedia-minio
|
||||||
|
|
@ -35,28 +38,34 @@ services:
|
||||||
environment:
|
environment:
|
||||||
MINIO_ROOT_USER: ${MINIO_ACCESS_KEY:-minioadmin}
|
MINIO_ROOT_USER: ${MINIO_ACCESS_KEY:-minioadmin}
|
||||||
MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY:-minioadmin}
|
MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY:-minioadmin}
|
||||||
|
# Localhost endpoints for MinIO S3 API and Web Console
|
||||||
|
MINIO_SERVER_URL: "http://localhost:${MINIO_PORT:-9000}"
|
||||||
|
MINIO_BROWSER_REDIRECT_URL: "http://localhost:${MINIO_CONSOLE_PORT:-9001}"
|
||||||
ports:
|
ports:
|
||||||
- "${MINIO_PORT:-9000}:9000"
|
# Bound strictly to 127.0.0.1 for local development
|
||||||
- "${MINIO_CONSOLE_PORT:-9001}:9001"
|
- "127.0.0.1:${MINIO_PORT:-9000}:9000"
|
||||||
|
- "127.0.0.1:${MINIO_CONSOLE_PORT:-9001}:9001"
|
||||||
volumes:
|
volumes:
|
||||||
- acupedia-minio-data:/data
|
- acupedia-minio-data:/data
|
||||||
networks:
|
networks:
|
||||||
- acupedia-net
|
- acupedia-net
|
||||||
# mailhog:
|
|
||||||
# image: mailhog/mailhog:latest
|
mailhog:
|
||||||
# container_name: acupedia-mailhog
|
image: mailhog/mailhog:latest
|
||||||
# restart: unless-stopped
|
container_name: acupedia-mailhog
|
||||||
# ports:
|
restart: unless-stopped
|
||||||
# - "1025:1025" # SMTP port
|
ports:
|
||||||
# - "8025:8025" # Web UI port
|
- "127.0.0.1:1025:1025" # SMTP port
|
||||||
# networks:
|
- "127.0.0.1:8025:8025" # Web UI port (http://localhost:8025)
|
||||||
# - acupedia-net
|
networks:
|
||||||
|
- acupedia-net
|
||||||
|
|
||||||
redisinsight:
|
redisinsight:
|
||||||
image: redis/redisinsight:latest
|
image: redis/redisinsight:latest
|
||||||
container_name: redis-insight
|
container_name: redis-insight
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- "5540:5540"
|
- "127.0.0.1:5540:5540"
|
||||||
volumes:
|
volumes:
|
||||||
- acupedia-redisinsight-data:/data
|
- acupedia-redisinsight-data:/data
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|
|
||||||
|
|
@ -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