Docker Deployment¶
This guide shows you how to deploy the FIRST Inference Gateway using Docker and Docker Compose.
Prerequisites¶
- Docker Desktop 4.29+ (or Docker Engine 24+) with Docker Compose v2
- Git
- Globus Account and registered applications
- At least 4GB RAM available for containers
Step 1: Clone the Repository¶
Step 2: Configure Environment¶
Create a .env file from the example environment file and customize the .env file following the instructions found in the example file:
Make sure you include all of the Globus UUIDs and secrets generated during the Globus setup stage. You can generate the SECRET_KEY variable with the following Django command (if installed):
python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())'
Production Security
For production deployments:
- Set
RUNNING_AUTOMATED_TEST_SUITE=False - Set
DEBUG=False - Use secure passwords and secrets
- Add your domain to
ALLOWED_HOSTSor use "*" if appropriate - Add at least one Globus High Assurance policy (
GLOBUS_POLICIES) - Set authorized IDP domains (
AUTHORIZED_IDP_DOMAINS) to match the policy - Consider using secrets management (e.g., Docker secrets)
Step 3: Start the Services¶
The docker-compose.yml includes:
Core Services¶
- inference-gateway: Django API application (internal port 8000)
- postgres: PostgreSQL 15 database (internal port 5432)
- redis: Redis 7 cache (internal port 6379)
- nginx: Reverse proxy (internal port 80 exposed to localhost port 8000)
Optional Services¶
You can add these to your compose file:
- prometheus: Metrics collection
- grafana: Visualization dashboard
Verify that the core-service containers are running:
Step 4: Initialize the Database¶
Run migrations:
docker-compose exec inference-gateway python manage.py makemigrations
docker-compose exec inference-gateway python manage.py migrate
Step 5: Test the Gateway¶
Check that the gateway is running:
If everything is running, the command should give you the following error:
Common Commands¶
View logs¶
Restart services¶
Stop services¶
Stop and remove volumes (clean slate)¶
Access container shell¶
Run Django management commands¶
Updating the Deployment¶
Pull latest changes:
git pull origin main
docker-compose build
docker-compose up -d
docker-compose exec inference-gateway python manage.py migrate
Troubleshooting¶
Gateway won't start¶
Check logs:
Common issues:
- Missing environment variables
- Database connection failed
- Port 8000 already in use
Database connection errors¶
Verify PostgreSQL is running:
Check database logs:
Can't access admin panel¶
Ensure you created a superuser:
502 Bad Gateway from Nginx¶
Vefiry that the gateway container is running:
Verify nginx configuration: