Skip to content

Production Setup Guide

Environment Setup

  1. Copy the production environment example file:
cd backend
cp production.env.example .env.production
  1. Edit the .env.production file:

  2. Set strong passwords for ENCRYPT_KEY, JWT_REFRESH_SECRET_KEY, JWT_RESET_SECRET_KEY

  3. Configure your database connection details
  4. Set up your SMTP settings for production email service
  5. Update Redis configuration
  6. Update CORS origins for your production domain

  7. Make sure the .env.production file is properly copied to the /app directory in the Docker container. This is handled by the Dockerfile.prod.

Common Issues

Application Startup Errors

If you see errors during application startup:

  1. Check that .env.production exists in the backend directory
  2. Verify that all required environment variables are set
  3. Ensure Redis settings match your Redis container configuration
  4. Make sure file permissions are correct in the container
  5. Check that paths and URLs are correct for production

Database Connection Issues

  1. If using PostgreSQL:

  2. Verify DATABASE_HOST, DATABASE_PORT, DATABASE_USER, DATABASE_PASSWORD are correct

  3. Check if PostgreSQL service is running and accessible

  4. If using Supabase:

  5. Verify POSTGRES_URL and other Supabase-related variables are set correctly
  6. Check if Supabase connection string includes all required parameters

Redis Connection Issues

  1. Verify Redis settings:
REDIS_HOST=fastapi_rbac_redis_server
REDIS_PORT=6379
REDIS_PASSWORD=your_secure_password
  1. Make sure Redis container is running:
    docker-compose -f docker-compose.prod.yml ps
    

Email Configuration

  1. Make sure SMTP settings are correct:
SMTP_HOST=your_smtp_server
SMTP_PORT=587
SMTP_USER=your_smtp_user
SMTP_PASSWORD=your_smtp_password
  1. Test email configuration with the email test endpoint

Security Settings

  1. Ensure all security keys are strong and unique:

  2. ENCRYPT_KEY

  3. JWT_REFRESH_SECRET_KEY
  4. JWT_RESET_SECRET_KEY
  5. SECRET_KEY

  6. Configure CORS for your production domain:

    BACKEND_CORS_ORIGINS=["https://your-domain.com"]
    

Deployment Steps

  1. Build production images:
docker-compose -f docker-compose.prod.yml build
  1. Start the services:
docker-compose -f docker-compose.prod.yml up -d
  1. Verify services are running:
docker-compose -f docker-compose.prod.yml ps
  1. Check logs for any errors:
    docker-compose -f docker-compose.prod.yml logs -f fastapi_rbac