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>
27 lines
614 B
Docker
27 lines
614 B
Docker
FROM python:3.12-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# Installer les dépendances système
|
|
RUN apt-get update && apt-get install -y \
|
|
gcc \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Installer Poetry
|
|
RUN pip install --no-cache-dir poetry
|
|
|
|
# Copier les fichiers backend et dépendances
|
|
COPY backend/ ./backend/
|
|
COPY pyproject.toml poetry.lock* ./
|
|
|
|
# Installer les dépendances Python
|
|
RUN poetry config virtualenvs.create false && \
|
|
poetry install --no-interaction --no-ansi --no-root
|
|
|
|
# Exposer le port
|
|
EXPOSE 8000
|
|
|
|
# Démarrer l'application
|
|
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000"]
|