================================================================================ SMARTBULLS BACKEND - PRODUCTION LIVE DEPLOYMENT GUIDE ================================================================================ This document outlines the step-by-step checklist and configuration changes required when deploying the SmartBulls backend from a staging server to the live production environment. -------------------------------------------------------------------------------- 1. SSL CERTIFICATE PATH CONFIGURATION -------------------------------------------------------------------------------- By default, the Nginx container is configured to use staging SSL paths. When moving to production, you must change the SSL certificate mappings. [Step 1.1] Open the Nginx config template file: /var/www/html/docker/nginx/default.conf.template [Step 1.2] Locate the SSL certificate lines inside the server block listening on port 443 (Lines 29-30): - FROM (Staging Paths): ssl_certificate /var/www/html/staging-cert/fullchain.pem; ssl_certificate_key /var/www/html/staging-cert/privkey.pem; - TO (Production Paths): ssl_certificate /var/www/html/live-certs/fullchain.pem; ssl_certificate_key /var/www/html/live-certs/privkey.pem; [Step 1.3] Ensure your live certificates (`fullchain.pem` and `privkey.pem`) are placed inside the corresponding directory on your host: /var/www/html/live-certs/ -------------------------------------------------------------------------------- 2. MYSQL DATABASE CREDENTIALS UPDATE -------------------------------------------------------------------------------- When deploying to a live server, you MUST change the default database usernames, passwords, and root keys to secure production secrets. [Step 2.1] Open the secure environment configuration file: /var/www/secure/.env [Step 2.2] Modify the following database variables to your live secure keys: DB_HOST=db DB_PORT=3306 DB_DATABASE=smartbulls_production DB_USER=smartbulls_prod_user DB_PWD=YourSecureComplexPassword123! MYSQL_ROOT_PASSWORD=YourSecureRootComplexPassword123! [Step 2.3] Open the docker-compose.yml file: /var/www/html/docker-compose.yml [Step 2.4] Verify the environment mapping inside the `db` service (Lines 74-78): MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-LeBhareKari@2024} MYSQL_DATABASE: ${DB_DATABASE:-smartbulls2026} MYSQL_USER: ${DB_USER:-satagestockbaba} MYSQL_PASSWORD: ${DB_PWD:-VandhoTOChhe@24} (Note: Docker-compose will automatically pull from your `.env` file first. The values after `:-` are safe fallback defaults). [Step 2.5] Recreate the MySQL DB container to apply new user credentials: $ docker-compose up -d --force-recreate db -------------------------------------------------------------------------------- 3. PHPMYADMIN PRODUCTION ROUTING -------------------------------------------------------------------------------- PhpMyAdmin requires updating the absolute routing URI to match the production domain, preventing redirect loops and cross-origin blocked resources. [Step 3.1] Open your docker-compose.yml file: /var/www/html/docker-compose.yml [Step 3.2] Locate the `phpmyadmin` service environment variables (Lines 107-114). [Step 3.3] Change the `PMA_ABSOLUTE_URI` variable: - FROM (Staging URL): PMA_ABSOLUTE_URI: https://app.edistry.com/phpmyadmin/ - TO (Production URL): PMA_ABSOLUTE_URI: https://yourproductiondomain.com/phpmyadmin/ -------------------------------------------------------------------------------- 4. NODE.JS API SERVICE ENVIRONMENT & FIREBASE UPDATES -------------------------------------------------------------------------------- The Express Node.js API reads dynamic secrets from `/var/www/secure/.env` for Firebase messaging and payment gateways. [Step 4.1] Open /var/www/secure/.env and update target production hosts: APPNAME=yourproductiondomain.com SERVICE_ACCOUNT_FILE=your-production-firebase-adminsdk.json [Step 4.2] Place your production Firebase Admin SDK json key in: /var/www/secure/your-production-firebase-adminsdk.json [Step 4.3] Update your production payment gateway keys for live transactions: RAZORPAY_KEY_ID=rzp_live_xxxxxxxxxxxx RAZORPAY_KEY_SECRET=xxxxxxxxxxxxxxxxxxxxxxxx RAZORPAY_WEBHOOK_SECRET=xxxxxxxxxxxxxxxxxxxx -------------------------------------------------------------------------------- 5. APPLYING CHANGES & REBUILDING CONTAINERS -------------------------------------------------------------------------------- After changing certificates, databases, and environments, execute these commands on the host server to cleanly rebuild and launch the microservice clusters: # 1. Pull down active container clusters $ docker-compose down # 2. Rebuild and launch all containers backgrounded with fresh configurations $ docker-compose up -d --build # 3. Check logs to ensure Nginx, Node API, and MySQL are connected perfectly: $ docker-compose logs -f --tail=50 ================================================================================