Inventario is configured for deployment on modern PaaS platforms like Railway and Render. The application uses Gunicorn as the WSGI server and WhiteNoise for efficient static file serving.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/margnes22/inventario-render/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- Python 3.11.9 (specified in
runtime.txt) - PostgreSQL database (recommended for production)
- Git repository with your code
Platform Configuration
Railway Deployment
Railway automatically detects Django applications and configures them appropriately.-
Connect your repository
- Link your GitHub repository to Railway
- Railway will detect the
Procfileandrequirements.txt
-
Configure environment variables
- Set all required environment variables (see Environment Variables)
- At minimum:
SECRET_KEY,DATABASE_URL,ALLOWED_HOSTS,CSRF_TRUSTED_ORIGINS
-
Deploy
- Railway will automatically run
pip install -r requirements.txt - The application starts with the command from
Procfile
- Railway will automatically run
Render Deployment
Render uses thebuild.sh script for automated builds.
-
Create a new Web Service
- Connect your GitHub repository
- Set build command:
./build.sh - Set start command:
gunicorn inventario.wsgi:application --log-file - --workers 2 --timeout 120
-
Configure environment variables
- Add all required variables in Render dashboard
- Render provides
DATABASE_URLautomatically if you add a PostgreSQL service
-
Deploy
- Render executes
build.shwhich:- Installs dependencies from
requirements.txt - Collects static files with
collectstatic - Applies database migrations
- Configures the Site domain
- Installs dependencies from
- Render executes
Gunicorn Configuration
The application runs with Gunicorn configured inProcfile:
--log-file -: Stream logs to stdout for platform log aggregation--workers 2: Run 2 worker processes (adjust based on available RAM)--timeout 120: 120-second timeout for long-running requests
For high-traffic deployments, calculate workers using:
(2 x CPU_cores) + 1Static Files with WhiteNoise
WhiteNoise serves static files efficiently without requiring a separate CDN for small to medium deployments. Configuration insettings.py:
- Compresses files with Brotli and gzip
- Adds far-future cache headers
- Serves files with minimal overhead
Build Script (build.sh)
The build script automates deployment preparation:Production Checklist
Before deploying to production:- Set
DEBUG=Falsein environment variables - Generate a strong
SECRET_KEY(usepython -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())') - Configure
ALLOWED_HOSTSwith your domain - Set
CSRF_TRUSTED_ORIGINSwith your full URL (includinghttps://) - Provision a PostgreSQL database and set
DATABASE_URL - Configure Google OAuth credentials (
GOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRET) - Set up email service (Resend API key)
- Configure optional services (OpenAI, Twilio) if needed
- Update Site domain in
build.shor via Django admin - Test all critical workflows (login, inventory operations, reports)
- Set up database backups
- Configure monitoring and error tracking
Post-Deployment
Create Superuser
After first deployment, create an admin user:Verify Configuration
- Access
/admin/and log in - Navigate to Sites and verify the domain is correct
- Check Social applications for Google OAuth configuration
- Test user registration and login flows
Monitoring
Monitor these metrics:- Application logs for errors
- Database connection pool usage
- Response times
- Static file serving
- Background job processing (if applicable)
Troubleshooting
Static files not loading
- Run
python manage.py collectstatic --clearto clear and rebuild - Verify
STATIC_ROOTdirectory is writable - Check WhiteNoise is in
MIDDLEWAREafterSecurityMiddleware
Database connection errors
- Verify
DATABASE_URLformat:postgresql://user:password@host:port/dbname - Check database server is accessible
- Ensure
psycopg2-binaryis installed
OAuth redirect errors
- Verify
CSRF_TRUSTED_ORIGINSincludes your domain with protocol - Check Site domain matches your deployment URL
- Update Google OAuth authorized redirect URIs
502 Bad Gateway
- Check Gunicorn worker timeout (increase if needed)
- Verify application is listening on correct port
- Review application logs for startup errors