Deployment
Production Docker builds, horizontal scaling, and clustering with Nginx load balancer.
Docker Hub
RecommendedPull the pre-built image from Docker Hub. This is the simplest and fastest way to deploy AuthMe in production.
# Download docker-compose.yml
curl -o docker-compose.yml \
https://raw.githubusercontent.com/Islamawad132/Authme/main/docker-compose.yml
# Create .env file with production values
cat > .env << 'EOF'
ADMIN_API_KEY=your-secure-api-key
ADMIN_PASSWORD=your-strong-password
BASE_URL=https://auth.example.com
EOF
# Start in detached mode
docker compose up -d
Uses the islamawad/authme:latest image with PostgreSQL 16 Alpine.
Build from Source
Build the Docker image locally from the source code. Useful if you need custom modifications.
git clone https://github.com/Islamawad132/Authme.git
cd Authme
# Build and start
docker compose -f docker-compose.dev.yml up -d --build Multi-Stage Dockerfile
The Dockerfile uses a 3-stage build to produce a lean production image:
Dependencies
Installs backend and Admin UI Node.js dependencies via npm ci
Build
Builds React Admin UI, generates Prisma client, compiles NestJS backend, prunes dev dependencies
Production
Final node:22-alpine image with only dist/, node_modules/, prisma/, and themes/
Container Entrypoint
The Docker entrypoint script (docker-entrypoint.sh) runs automatically on every container start:
- 1
Validates that
DATABASE_URLis set (exits with helpful error if missing) - 2
Runs
npx prisma migrate deployto apply any pending database migrations - 3
Launches the server with
node dist/main.js
Horizontal Scaling
AuthMe is fully stateless — all state lives in PostgreSQL. You can run any number of instances behind a load balancer sharing the same database.
Cluster with Nginx
Use the cluster compose file to run 2 instances behind an Nginx reverse proxy:
docker compose -f docker-compose.cluster.yml up -d Cluster Topology
┌────────────────────────────────────────────┐
│ Nginx Load Balancer │
│ :8080 → :80 │
└─────────┬──────────────────┬───────────────┘
│ │
┌───────┴──────┐ ┌───────┴──────┐
│ AuthMe #1 │ │ AuthMe #2 │
│ :3000 │ │ :3000 │
└───────┬──────┘ └───────┬──────┘
│ │
┌───────┴──────────────────┴───────┐
│ PostgreSQL 16 │
│ (shared) │
└──────────────────────────────────┘ Nginx Configuration
upstream authme {
server app1:3000;
server app2:3000;
}
server {
listen 80;
server_name _;
location / {
proxy_pass http://authme;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
} Manual Scaling
Scale to any number of instances using the Docker Compose scale flag:
docker compose up -d --scale app=3