new base for gitea
This commit is contained in:
3
backend/Dockerfile.dev → backend/Dockerfile
Executable file → Normal file
3
backend/Dockerfile.dev → backend/Dockerfile
Executable file → Normal file
@@ -40,9 +40,6 @@ RUN mkdir -p /app/uploads /app/logs
|
||||
# Code source
|
||||
COPY . .
|
||||
|
||||
# Env dev
|
||||
COPY .env.development .env
|
||||
|
||||
# Permissions
|
||||
RUN chmod -R 755 /app
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
# Multi-stage build pour la production
|
||||
FROM python:3.11-slim AS builder
|
||||
|
||||
LABEL maintainer="LeDiscord Team"
|
||||
LABEL version="1.0"
|
||||
LABEL description="LeDiscord Backend - Environnement Production"
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Env
|
||||
ENV ENVIRONMENT=production \
|
||||
PYTHONPATH=/app \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1
|
||||
|
||||
# Dépendances de build
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
gcc \
|
||||
libpq-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Requirements
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir --upgrade pip \
|
||||
&& pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# ---- Stage runtime ----
|
||||
FROM python:3.11-slim AS production
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Env runtime
|
||||
ENV ENVIRONMENT=production \
|
||||
PYTHONPATH=/app \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1
|
||||
|
||||
# Dépendances runtime
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libpq5 \
|
||||
libmagic1 \
|
||||
libgl1 \
|
||||
libglib2.0-0 \
|
||||
libsm6 \
|
||||
libxext6 \
|
||||
libxrender1 \
|
||||
libgomp1 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Paquets Python depuis le builder
|
||||
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
|
||||
COPY --from=builder /usr/local/bin /usr/local/bin
|
||||
|
||||
# Dossiers appli
|
||||
RUN mkdir -p /app/uploads /app/logs
|
||||
|
||||
# Code source
|
||||
COPY . .
|
||||
|
||||
# Env prod (attention à ce que tu y mets)
|
||||
COPY .env.production .env
|
||||
|
||||
# Utilisateur non-root
|
||||
RUN groupadd -r lediscord && useradd -r -g lediscord lediscord \
|
||||
&& chown -R lediscord:lediscord /app
|
||||
USER lediscord
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
# Healthcheck (optionnel mais pratique)
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
||||
CMD python -c "import socket; s=socket.socket(); s.settimeout(2); s.connect(('127.0.0.1',8000)); s.close()" || exit 1
|
||||
|
||||
# Démarrage uvicorn — pas de guillemets imbriqués ici
|
||||
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "4", "--log-level", "info", "--proxy-headers", "--forwarded-allow-ips=*"]
|
||||
0
backend/__init__.py
Executable file → Normal file
0
backend/__init__.py
Executable file → Normal file
0
backend/api/routers/__init__.py
Executable file → Normal file
0
backend/api/routers/__init__.py
Executable file → Normal file
0
backend/api/routers/admin.py
Executable file → Normal file
0
backend/api/routers/admin.py
Executable file → Normal file
0
backend/api/routers/albums.py
Executable file → Normal file
0
backend/api/routers/albums.py
Executable file → Normal file
0
backend/api/routers/auth.py
Executable file → Normal file
0
backend/api/routers/auth.py
Executable file → Normal file
0
backend/api/routers/events.py
Executable file → Normal file
0
backend/api/routers/events.py
Executable file → Normal file
0
backend/api/routers/information.py
Executable file → Normal file
0
backend/api/routers/information.py
Executable file → Normal file
0
backend/api/routers/notifications.py
Executable file → Normal file
0
backend/api/routers/notifications.py
Executable file → Normal file
0
backend/api/routers/posts.py
Executable file → Normal file
0
backend/api/routers/posts.py
Executable file → Normal file
0
backend/api/routers/settings.py
Executable file → Normal file
0
backend/api/routers/settings.py
Executable file → Normal file
0
backend/api/routers/stats.py
Executable file → Normal file
0
backend/api/routers/stats.py
Executable file → Normal file
0
backend/api/routers/tickets.py
Executable file → Normal file
0
backend/api/routers/tickets.py
Executable file → Normal file
0
backend/api/routers/users.py
Executable file → Normal file
0
backend/api/routers/users.py
Executable file → Normal file
0
backend/api/routers/vlogs.py
Executable file → Normal file
0
backend/api/routers/vlogs.py
Executable file → Normal file
0
backend/app.py
Executable file → Normal file
0
backend/app.py
Executable file → Normal file
0
backend/config/database.py
Executable file → Normal file
0
backend/config/database.py
Executable file → Normal file
6
backend/config/settings.py
Executable file → Normal file
6
backend/config/settings.py
Executable file → Normal file
@@ -8,7 +8,7 @@ class Settings:
|
||||
# Environnement - OBLIGATOIRE
|
||||
ENVIRONMENT: str = os.getenv("ENVIRONMENT")
|
||||
if not ENVIRONMENT:
|
||||
raise ValueError("ENVIRONMENT variable is required. Use .env.local, .env.development, or .env.production")
|
||||
raise ValueError("ENVIRONMENT variable is required. Use development or production")
|
||||
|
||||
# Debug et reload
|
||||
DEBUG: bool = os.getenv("DEBUG", "false").lower() == "true"
|
||||
@@ -106,10 +106,6 @@ try:
|
||||
settings = Settings()
|
||||
except ValueError as e:
|
||||
print(f"❌ Erreur de configuration: {e}")
|
||||
print("💡 Assurez-vous d'utiliser un fichier d'environnement spécifique:")
|
||||
print(" - .env.local pour le développement local")
|
||||
print(" - .env.development pour l'environnement de développement")
|
||||
print(" - .env.production pour la production")
|
||||
raise
|
||||
|
||||
# Validation automatique au démarrage
|
||||
|
||||
0
backend/models/__init__.py
Executable file → Normal file
0
backend/models/__init__.py
Executable file → Normal file
0
backend/models/album.py
Executable file → Normal file
0
backend/models/album.py
Executable file → Normal file
0
backend/models/event.py
Executable file → Normal file
0
backend/models/event.py
Executable file → Normal file
0
backend/models/information.py
Executable file → Normal file
0
backend/models/information.py
Executable file → Normal file
0
backend/models/notification.py
Executable file → Normal file
0
backend/models/notification.py
Executable file → Normal file
0
backend/models/post.py
Executable file → Normal file
0
backend/models/post.py
Executable file → Normal file
0
backend/models/settings.py
Executable file → Normal file
0
backend/models/settings.py
Executable file → Normal file
0
backend/models/ticket.py
Executable file → Normal file
0
backend/models/ticket.py
Executable file → Normal file
0
backend/models/user.py
Executable file → Normal file
0
backend/models/user.py
Executable file → Normal file
0
backend/models/vlog.py
Executable file → Normal file
0
backend/models/vlog.py
Executable file → Normal file
1
backend/requirements.txt
Executable file → Normal file
1
backend/requirements.txt
Executable file → Normal file
@@ -5,6 +5,7 @@ alembic==1.12.1
|
||||
psycopg2-binary==2.9.9
|
||||
python-jose[cryptography]==3.3.0
|
||||
passlib[bcrypt]==1.7.4
|
||||
bcrypt==4.0.1
|
||||
python-multipart==0.0.6
|
||||
python-dotenv==1.0.0
|
||||
pydantic==2.5.0
|
||||
|
||||
0
backend/schemas/__init__.py
Executable file → Normal file
0
backend/schemas/__init__.py
Executable file → Normal file
0
backend/schemas/album.py
Executable file → Normal file
0
backend/schemas/album.py
Executable file → Normal file
0
backend/schemas/event.py
Executable file → Normal file
0
backend/schemas/event.py
Executable file → Normal file
0
backend/schemas/information.py
Executable file → Normal file
0
backend/schemas/information.py
Executable file → Normal file
0
backend/schemas/notification.py
Executable file → Normal file
0
backend/schemas/notification.py
Executable file → Normal file
0
backend/schemas/post.py
Executable file → Normal file
0
backend/schemas/post.py
Executable file → Normal file
0
backend/schemas/settings.py
Executable file → Normal file
0
backend/schemas/settings.py
Executable file → Normal file
0
backend/schemas/ticket.py
Executable file → Normal file
0
backend/schemas/ticket.py
Executable file → Normal file
0
backend/schemas/user.py
Executable file → Normal file
0
backend/schemas/user.py
Executable file → Normal file
0
backend/schemas/vlog.py
Executable file → Normal file
0
backend/schemas/vlog.py
Executable file → Normal file
@@ -1,84 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Script de test pour vérifier la configuration des environnements
|
||||
Usage: python test_config.py [local|development|production]
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
def test_environment(env_name: str):
|
||||
"""Teste la configuration d'un environnement spécifique"""
|
||||
print(f"🔍 Test de la configuration {env_name.upper()}")
|
||||
print("=" * 50)
|
||||
|
||||
# Définir l'environnement
|
||||
os.environ["ENVIRONMENT"] = env_name
|
||||
|
||||
try:
|
||||
# Importer la configuration
|
||||
from config.settings import settings
|
||||
|
||||
print(f"✅ Configuration chargée avec succès")
|
||||
print(f" Environnement détecté: {settings.ENVIRONMENT}")
|
||||
print(f" Debug: {settings.DEBUG}")
|
||||
print(f" Reload: {settings.RELOAD}")
|
||||
print(f" Log Level: {settings.LOG_LEVEL}")
|
||||
print(f" Workers: {settings.WORKERS}")
|
||||
print(f" CORS Origins: {', '.join(settings.CORS_ORIGINS)}")
|
||||
print(f" Upload Path: {settings.UPLOAD_PATH}")
|
||||
print(f" Database: {settings.DATABASE_URL.split('@')[1] if '@' in settings.DATABASE_URL else 'Unknown'}")
|
||||
|
||||
# Validation
|
||||
if settings.validate():
|
||||
print(f"✅ Configuration {env_name} validée avec succès")
|
||||
else:
|
||||
print(f"❌ Configuration {env_name} invalide")
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Erreur lors du chargement de la configuration {env_name}: {e}")
|
||||
return False
|
||||
|
||||
print()
|
||||
return True
|
||||
|
||||
def main():
|
||||
"""Fonction principale"""
|
||||
print("🚀 Test de configuration LeDiscord Backend")
|
||||
print("=" * 60)
|
||||
|
||||
# Vérifier que nous sommes dans le bon répertoire
|
||||
if not Path("config/settings.py").exists():
|
||||
print("❌ Erreur: Ce script doit être exécuté depuis le répertoire backend/")
|
||||
sys.exit(1)
|
||||
|
||||
# Test des environnements
|
||||
environments = ["local", "development", "production"]
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
env_arg = sys.argv[1].lower()
|
||||
if env_arg in environments:
|
||||
environments = [env_arg]
|
||||
else:
|
||||
print(f"❌ Environnement invalide: {env_arg}")
|
||||
print(f" Environnements valides: {', '.join(environments)}")
|
||||
sys.exit(1)
|
||||
|
||||
success_count = 0
|
||||
for env in environments:
|
||||
if test_environment(env):
|
||||
success_count += 1
|
||||
|
||||
print("=" * 60)
|
||||
print(f"📊 Résultats: {success_count}/{len(environments)} configurations valides")
|
||||
|
||||
if success_count == len(environments):
|
||||
print("🎉 Toutes les configurations sont valides !")
|
||||
return 0
|
||||
else:
|
||||
print("⚠️ Certaines configurations ont des problèmes")
|
||||
return 1
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
0
backend/utils/email.py
Executable file → Normal file
0
backend/utils/email.py
Executable file → Normal file
0
backend/utils/init_db.py
Executable file → Normal file
0
backend/utils/init_db.py
Executable file → Normal file
0
backend/utils/notification_service.py
Executable file → Normal file
0
backend/utils/notification_service.py
Executable file → Normal file
0
backend/utils/security.py
Executable file → Normal file
0
backend/utils/security.py
Executable file → Normal file
0
backend/utils/settings_service.py
Executable file → Normal file
0
backend/utils/settings_service.py
Executable file → Normal file
0
backend/utils/video_utils.py
Executable file → Normal file
0
backend/utils/video_utils.py
Executable file → Normal file
Reference in New Issue
Block a user