AuthX — Docker Deployment
This document describes how to run AuthX using Docker Compose.
On this page ▾
AuthX supports two Docker deployment modes:
- Standalone AuthX — runs AuthX with its required infrastructure.
- DjangoPlay Full Stack — runs AuthX together with DjangoPlay, PostgreSQL, Redis, and Celery.
Docker deployment is primarily intended for local development, integration testing, and controlled self-hosted environments.
1. Deployment Modes
Standalone AuthX
Use standalone deployment when AuthX needs to run independently.
Docker Compose
│
▼
AuthX
│
▼
PostgreSQL
`DjangoPlay Full Stack
Use the full-stack definition when testing the complete DjangoPlay platform.
Docker Compose
│
┌────────────────┼────────────────┐
│ │ │
▼ ▼ ▼
AuthX DjangoPlay Celery
│ │ │
└────────────────┼────────────────┘
│
┌───────┴───────┐
▼ ▼
PostgreSQL RedisAuthX and DjangoPlay remain separate application services while sharing the Compose-managed infrastructure required by the full stack.
2. Prerequisites
Install:
- Docker
- Docker Compose
Verify:
docker --version
docker compose version3. Standalone AuthX Deployment
3.1 Configure Environment
Create the environment file from the example:
cp env.example .envConfigure the required AuthX settings in .env.
Sensitive values such as:
POSTGRES_PASSWORD
JWT_PRIVATE_KEY
JWT_PUBLIC_KEY
AUTHX_SERVICE_TOKENmust not be committed to source control.
3.2 Build and Start
Start AuthX:
docker compose up --buildThe container initializes the database schema before starting the application.
The AuthX application is started with:
alembic upgrade head
uvicorn authx.main:app
--host 0.0.0.0
--port 8100
--workers 2The application is therefore available on:
http://localhost:81004. Running in Detached Mode
For background execution:
docker compose up --build -dCheck running containers:
docker compose psView AuthX logs:
docker compose logs -f authxIf the Compose service has a different name, use:
docker compose config --servicesto display the available service names.
5. Health Check
AuthX exposes a health endpoint:
curl http://localhost:8100/healthA healthy installation should return the logical result:
{
"status": "ok",
"service": "authx"
}The health endpoint confirms that the AuthX application is responding.
It should not be treated as a complete dependency-health check unless the implementation explicitly performs those dependency checks.
6. Full DjangoPlay Stack
The repository also provides a full-stack Docker Compose definition:
docker compose -f docker-compose.fullstack.yml up -dThe full-stack environment brings up the principal DjangoPlay runtime components:
AuthX
DjangoPlay
Celery
PostgreSQL
RedisConceptually:
Full Stack
│
┌───────────────┼────────────────┐
│ │ │
▼ ▼ ▼
AuthX DjangoPlay Celery
│ │ │
│ └───────┬────────┘
│ │
▼ ▼
PostgreSQL RedisThis mode is useful when testing authentication, application APIs, background processing, and infrastructure together.
7. PostgreSQL Initialization
The full-stack Compose environment mounts:
infra/init-db.sqlThe initialization script creates separate databases for the two applications:
authx
djangoplayThe logical database layout is:
PostgreSQL
│
├── authx
│ └── AuthX identity data
│
└── djangoplay
└── DjangoPlay application dataThis separation keeps AuthX identity persistence independent from the DjangoPlay application database even when both applications use the same PostgreSQL server.
8. Database Initialization Behaviour
PostgreSQL initialization scripts mounted into the official PostgreSQL container are normally executed when the database volume is initialized.
Therefore, changing:
infra/init-db.sqldoes not necessarily recreate databases in an already-initialized Docker volume.
For a fresh local environment, the volume can be removed and recreated:
docker compose -f docker-compose.fullstack.yml down -vThen start the stack again:
docker compose -f docker-compose.fullstack.yml up -dWarning: removing volumes deletes the data stored in those Docker volumes. Use this only when the local data can safely be discarded.
9. Database Migrations
AuthX database migrations are handled through Alembic:
alembic upgrade headWhen running AuthX through its Docker deployment, the migration step is executed before the Uvicorn application process starts.
The important sequence is:
Container Start
│
▼
Alembic Migration
│
▼
Database Ready
│
▼
Uvicorn
│
▼
AuthX APIThis prevents the application from starting against an unapplied AuthX migration state.
10. Stopping the Environment
Stop the standalone environment:
docker compose downStop the full stack:
docker compose -f docker-compose.fullstack.yml downStopping the containers does not normally remove persistent Docker volumes.
11. Rebuilding the Environment
After changing application code or Docker configuration:
docker compose up --buildFor the full stack:
docker compose -f docker-compose.fullstack.yml up --buildTo force recreation of containers:
docker compose up --build --force-recreateUse --force-recreate when configuration changes are not being reflected in
existing containers.
12. Inspecting the Environment
List services:
docker compose psInspect the resolved Compose configuration:
docker compose configView all logs:
docker compose logsFollow logs:
docker compose logs -fView only AuthX logs:
docker compose logs -f authxCheck the container directly:
docker ps13. Common Docker Issues
AuthX Does Not Start
Check the logs:
docker compose logs authxLook for:
- Missing environment variables
- Database connection failures
- Invalid JWT key configuration
- Migration errors
- Port conflicts
Database Connection Failure
Verify that the configured database host points to the Compose service
name, not localhost, when AuthX is running inside Docker.
Inside a Compose network:
AuthX container
│
│ PostgreSQL service name
▼
PostgreSQL containerlocalhost inside the AuthX container refers to the AuthX container itself,
not the PostgreSQL container.
Port 8100 Already in Use
Check which process is using the port:
lsof -i :8100Stop the conflicting process or change the host-side port mapping in the Compose configuration.
The AuthX application itself continues to listen on:
0.0.0.0:8100inside the container unless the deployment configuration changes it.
Database Changes Are Not Applied
Check the migration state:
alembic currentUpgrade:
alembic upgrade headFor a disposable local full-stack database, recreating the PostgreSQL volume is another option:
docker compose -f docker-compose.fullstack.yml down -v
docker compose -f docker-compose.fullstack.yml up --build -d14. Configuration and Secrets
Docker does not remove the requirement to protect AuthX secrets.
Do not commit:
.env
JWT_PRIVATE_KEY
JWT_PUBLIC_KEY
AUTHX_SERVICE_TOKEN
POSTGRES_PASSWORDUse environment-specific secret management for shared or production environments.
The RSA private key is particularly sensitive because it controls AuthX JWT signing.
The public key may be distributed to consumers for JWT verification.
15. Docker Networking
In a Compose deployment, services communicate through the Docker network using service names.
Conceptually:
Docker Network
│
┌──────────┼──────────┐
│ │ │
▼ ▼ ▼
AuthX PostgreSQL Redis
│
▼
DjangoPlayApplications should use the Compose service name for container-to-container communication.
Hostnames such as:
localhost
127.0.0.1refer to the current container when used from inside a container and should not normally be used to reach another Compose service.
16. Standalone vs Full Stack
| Mode | Use Case |
|---|---|
| Standalone | Develop or test AuthX independently |
| Full Stack | Test AuthX together with DjangoPlay |
| Standalone | Debug AuthX authentication and identity behaviour |
| Full Stack | Validate DjangoPlay ↔ AuthX integration |
| Full Stack | Test PostgreSQL + Redis + Celery workflows |
The standalone deployment is the preferred choice when only AuthX needs to be tested.
The full-stack deployment is appropriate when testing the complete DjangoPlay platform.
17. Docker Deployment Architecture
flowchart TD
USER["Browser / API Client"]
subgraph COMPOSE["Docker Compose"]
AUTHX["AuthX<br/><small>Uvicorn + Alembic</small>"]
DJANGO["DjangoPlay<br/><small>Django + Gunicorn</small>"]
CELERY["Celery<br/><small>Background Worker</small>"]
POSTGRES["PostgreSQL"]
REDIS["Redis"]
end
USER --> AUTHX
USER --> DJANGO
AUTHX --> POSTGRES
DJANGO --> POSTGRES
DJANGO --> REDIS
CELERY --> REDIS
CELERY --> POSTGRES
DJANGO -->|"Identity operations / JWT integration"| AUTHX
classDef client fill:#f5f3ed,stroke:#777,stroke-width:1px,color:#444
classDef app fill:#e5f6f1,stroke:#159a7a,stroke-width:2px,color:#075d4b
classDef infra fill:#e6f1fb,stroke:#2474b5,stroke-width:2px,color:#174d7a
class USER client
class AUTHX,DJANGO,CELERY app
class POSTGRES,REDIS infraThe diagram represents the full-stack deployment model. Standalone AuthX deployment uses only the services defined by the standalone Compose configuration.
18. Deployment Summary
AuthX can be deployed through Docker Compose without requiring a separate Python runtime on the host.
The standard standalone workflow is:
cp env.example .env
# Configure .env
docker compose up --buildVerify:
curl http://localhost:8100/healthThe DjangoPlay integrated environment is started with:
docker compose -f docker-compose.fullstack.yml up -dThe full-stack environment provides:
AuthX
DjangoPlay
PostgreSQL
Redis
CeleryDocker therefore provides a reproducible deployment boundary for local AuthX development and for testing the complete DjangoPlay platform.