- Python 3.8+
- Node.js 18+
- npm or yarn
- Clone the repository
- Create a Python virtual environment:
python -m venv venv source venv/bin/activate # On Windows use: venv\Scripts\activate
- Install Python dependencies:
pip install -r requirements.txt
- Install UI dependencies:
cd ui npm install
-
Initialize the environment configuration:
python init-env.py
This script will:
- Generate secure random keys
- Set up database configuration
- Configure email settings (optional)
- Create a
.envfile from.env.example
-
Initialize the database:
python init-db.py
-
Start the backend server:
python run.py
The API will be available at http://127.0.0.1:5002
-
Start the frontend development server:
cd ui npm run devThe UI will be available at http://localhost:5000
The following environment variables can be configured in .env:
FLASK_ENV: development/production/testingSECRET_KEY: Session management keyJWT_SECRET_KEY: JWT token signing keyDATABASE_URL: Database connection string
- Email Configuration (SMTP)
- Security Settings
- OTP Configuration
- Logging Options
- Session Keys
- Model Configuration
- Template Paths
- Export Settings
See .env.example for all available configuration options.
- Docker Engine 20.10+
- Docker Compose 2.0+
-
Clone the repository
git clone <repository-url> cd auth
-
Build and run with Docker Compose
cd container docker-compose up -dThe application will be available at: https://localhost:8443
The Docker setup supports the following environment variables:
ENV_FILE_PATH: Path to mount your custom.envfile (default:./docker-volumes/config)DB_VOLUME_PATH: Path for database persistence (default:./docker-volumes/db)SSL_VOLUME_PATH: Path for SSL certificates (default:./docker-volumes/ssl)INSTANCE_VOLUME_PATH: Path for instance files (default:./docker-volumes/instance)
The Docker setup uses the following volume mounts:
volumes:
# Environment configuration
- ${ENV_FILE_PATH:-./docker-volumes/config}:/app/config
# Database files
- ${DB_VOLUME_PATH:-./docker-volumes/db}:/app/db
# SSL certificates
- ${SSL_VOLUME_PATH:-./docker-volumes/ssl}:/app/ssl
# Instance configuration
- ${INSTANCE_VOLUME_PATH:-./docker-volumes/instance}:/app/instanceTo use a custom .env file:
-
Create your configuration directory
mkdir -p /path/to/your/config
-
Create your
.envfile# Example: /path/to/your/config/.env FLASK_ENV=production SECRET_KEY=your-secret-key JWT_SECRET_KEY=your-jwt-secret DATABASE_URL=sqlite:///db/local.db # Mail Configuration MAIL_SERVER=smtp.gmail.com MAIL_PORT=587 MAIL_USE_TLS=true MAIL_USERNAME=your-email@gmail.com MAIL_PASSWORD=your-app-password MAIL_DEFAULT_SENDER=noreply@yourdomain.com
-
Run with custom environment file
ENV_FILE_PATH=/path/to/your/config docker-compose up -d
On first run, the container automatically generates a self-signed SSL certificate. The certificate will be stored in the SSL volume mount and reused on subsequent runs.
To use your own SSL certificates:
-
Place your certificates in the SSL volume directory
mkdir -p docker-volumes/ssl cp your-cert.pem docker-volumes/ssl/cert.pem cp your-private-key.pem docker-volumes/ssl/key.pem
-
Ensure proper permissions
chmod 644 docker-volumes/ssl/cert.pem chmod 600 docker-volumes/ssl/key.pem
-
Start the container
docker-compose up -d
The database files are stored in the database volume mount. To backup or restore:
# Backup
cp docker-volumes/db/local.db backup-$(date +%Y%m%d).db
# Restore
cp backup-20241201.db docker-volumes/db/local.dbFor development with live code reloading:
# Mount the source code as a volume for development
docker-compose -f docker-compose.yml -f docker-compose.dev.yml upView application logs:
docker-compose logs -f auth-appCheck health status:
docker-compose psThe container includes a health check that verifies the HTTPS endpoint every 30 seconds.
Create different compose files for different environments:
# Production
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
# Development
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -dTo use a different port:
# Use port 9443 instead of 8443
docker-compose up -d --env FLASK_RUN_PORT=9443Or modify the docker-compose.yml file to change the port mapping.
-
Permission Errors
# Fix volume permissions sudo chown -R 1000:1000 docker-volumes/ -
SSL Certificate Issues
# Regenerate SSL certificates rm docker-volumes/ssl/cert.pem docker-volumes/ssl/key.pem docker-compose restart auth-app -
Database Issues
# Reset database rm docker-volumes/db/local.db docker-compose restart auth-app -
Environment File Not Found
# Check mount path docker-compose exec auth-app ls -la /app/config/