Comprehensive Docker Compose setup with all services:
Services:
• MariaDB 11 - Database with persistent storage
• FastAPI Backend - Python 3.12 with Poetry
• Next.js Frontend - Node 20 with production build
• Adminer - Optional database management UI
Features:
✓ Health checks for all services
✓ Proper dependency ordering (database -> backend -> frontend)
✓ Networking with private subnet (172.20.0.0/16)
✓ Volume management for data persistence
✓ Environment variable configuration
✓ Logging configuration (10MB max, 3 files)
✓ Restart policies (unless-stopped)
Configuration Files:
• docker-compose.yml - Production-ready compose file
• .env - Development environment variables
• .env.example - Template for environment setup
• DOCKER_SETUP.md - Comprehensive setup guide
Improvements:
• Added curl to backend Dockerfile for health checks
• Better error handling and startup sequencing
• Database initialization with multiple SQL files
• Adminer for easy database management (port 8080)
• Detailed logging with file rotation
• Production-ready with comments and documentation
Environment Variables:
Database:
DB_HOST=mariadb, DB_PORT=3306
DB_NAME=evoting_db, DB_USER=evoting_user
DB_PASSWORD=evoting_pass123
Services:
BACKEND_PORT=8000, FRONTEND_PORT=3000
Security:
SECRET_KEY=your-secret-key-change-in-production
DEBUG=false (for production)
Health Checks:
• Database: mariadb-admin ping
• Backend: curl /health endpoint
• Frontend: wget to port 3000
Volumes:
• evoting_data - MariaDB persistent storage
• backend_cache - Backend cache directory
Networks:
• evoting_network (172.20.0.0/16)
• Internal service-to-service communication
Quick Start:
1. cp .env.example .env
2. docker-compose up -d
3. http://localhost:3000 (frontend)
4. http://localhost:8000/docs (API docs)
5. http://localhost:8080 (database admin)
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
39 lines
1.0 KiB
Plaintext
39 lines
1.0 KiB
Plaintext
# ================================================================
|
|
# E-VOTING SYSTEM - ENVIRONMENT EXAMPLE
|
|
# Copy this file to .env and adjust values for your environment
|
|
# ================================================================
|
|
|
|
# Database Configuration
|
|
DB_HOST=mariadb
|
|
DB_PORT=3306
|
|
DB_NAME=evoting_db
|
|
DB_USER=evoting_user
|
|
DB_PASSWORD=evoting_pass123
|
|
DB_ROOT_PASSWORD=rootpass123
|
|
|
|
# Backend Configuration
|
|
BACKEND_PORT=8000
|
|
SECRET_KEY=change-this-to-a-strong-random-key-in-production
|
|
DEBUG=false
|
|
PYTHONUNBUFFERED=1
|
|
|
|
# Frontend Configuration
|
|
FRONTEND_PORT=3000
|
|
NEXT_PUBLIC_API_URL=http://localhost:8000
|
|
|
|
# ElGamal Cryptography Parameters
|
|
ELGAMAL_P=23
|
|
ELGAMAL_G=5
|
|
|
|
# JWT Configuration
|
|
ACCESS_TOKEN_EXPIRE_MINUTES=30
|
|
ALGORITHM=HS256
|
|
|
|
# Production Recommendations:
|
|
# 1. Change SECRET_KEY to a strong random value
|
|
# 2. Set DEBUG=false
|
|
# 3. Update DB_PASSWORD to a strong password
|
|
# 4. Use HTTPS and set NEXT_PUBLIC_API_URL to production domain
|
|
# 5. Configure proper database backups
|
|
# 6. Use environment-specific secrets management
|