Correction gunicorn

This commit is contained in:
ifaryd
2026-05-26 09:23:41 +00:00
parent 0c52766f8a
commit 8e28e61c65
7 changed files with 99 additions and 21 deletions

View File

@@ -1,4 +1,5 @@
# Copier ce fichier en .env.dev et remplir les valeurs # Copier ce fichier en .env.dev et remplir les valeurs
# Générer SECRET_KEY : python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"
SECRET_KEY=change-this-to-a-long-random-string-50-chars-minimum SECRET_KEY=change-this-to-a-long-random-string-50-chars-minimum
@@ -13,7 +14,13 @@ DJANGO_SETTINGS_MODULE=config.settings.prod
ALLOWED_HOSTS=dev.jool-international.com ALLOWED_HOSTS=dev.jool-international.com
SECURE_SSL_REDIRECT=true SECURE_SSL_REDIRECT=true
# Email (optionnel pour le dev) # Fonctionnalités
CAREERS_ENABLED=False
# Email
DEFAULT_FROM_EMAIL=noreply@jool-int.com
CAREERS_NOTIFY_EMAIL=rh@jool-int.com
CONTACT_NOTIFY_EMAIL=contacts@jool-int.com
EMAIL_HOST=smtp.dreamhost.com EMAIL_HOST=smtp.dreamhost.com
EMAIL_PORT=465 EMAIL_PORT=465
EMAIL_HOST_USER= EMAIL_HOST_USER=

View File

@@ -1,10 +1,8 @@
dev.jool-international.com { dev.jool-international.com {
# HTTPS automatique via Let's Encrypt (aucune config SSL nécessaire) # Fichiers statiques Django
handle_path /static/* {
# Fichiers statiques root * /app/staticfiles
handle /static/* {
root * /app
file_server file_server
} }
@@ -14,8 +12,8 @@ dev.jool-international.com {
} }
# Autres fichiers media # Autres fichiers media
handle /media/* { handle_path /media/* {
root * /app root * /app/media
file_server file_server
} }
@@ -24,7 +22,6 @@ dev.jool-international.com {
reverse_proxy web:8000 reverse_proxy web:8000
} }
# Logs
log { log {
output stdout output stdout
} }

31
Caddyfile.local Normal file
View File

@@ -0,0 +1,31 @@
# Config Caddy locale — http uniquement sur localhost:8888
# Pas de SSL, pas de vrai domaine nécessaire
:80 {
# Fichiers statiques Django
handle_path /static/* {
root * /app/staticfiles
file_server
}
# CVs : jamais accessibles publiquement
handle /media/careers/cvs/* {
respond 404
}
# Autres fichiers media
handle_path /media/* {
root * /app/media
file_server
}
# Application Django
handle {
reverse_proxy web:8000
}
log {
output stdout
}
}

View File

@@ -14,9 +14,14 @@ fi
echo "✅ .env.dev trouvé" echo "✅ .env.dev trouvé"
# ── 2. Build et démarrage ───────────────────────────────── # ── 2. Pull du dernier code ───────────────────────────────
echo "📥 Récupération du dernier code..."
git pull
# ── 3. Build sans cache + démarrage ──────────────────────
echo "🚀 Build et démarrage des conteneurs..." echo "🚀 Build et démarrage des conteneurs..."
$COMPOSE up -d --build $COMPOSE build --no-cache
$COMPOSE up -d
echo "" echo ""
echo "✅ Déploiement terminé !" echo "✅ Déploiement terminé !"

View File

@@ -0,0 +1,45 @@
services:
db:
image: postgres:16-alpine
restart: always
volumes:
- postgres_data_caddy_local:/var/lib/postgresql/data
env_file: .env.prod
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
interval: 10s
timeout: 5s
retries: 5
web:
build: .
restart: always
env_file: .env.prod
environment:
ALLOWED_HOSTS: localhost,127.0.0.1,web
SECURE_SSL_REDIRECT: "false"
volumes:
- static_volume_caddy_local:/app/staticfiles
- media_volume_caddy_local:/app/media
depends_on:
db:
condition: service_healthy
command: sh -c "python manage.py migrate --noinput && gunicorn config.wsgi:application --bind 0.0.0.0:8000 --workers 2 --timeout 60 --access-logfile - --error-logfile -"
caddy:
image: caddy:2-alpine
restart: always
ports:
- "8890:80"
volumes:
- ./Caddyfile.local:/etc/caddy/Caddyfile:ro
- static_volume_caddy_local:/app/staticfiles:ro
- media_volume_caddy_local:/app/media:ro
depends_on:
- web
volumes:
postgres_data_caddy_local:
static_volume_caddy_local:
media_volume_caddy_local:

View File

@@ -8,7 +8,7 @@ services:
- postgres_data_dev:/var/lib/postgresql/data - postgres_data_dev:/var/lib/postgresql/data
env_file: .env.dev env_file: .env.dev
healthcheck: healthcheck:
test: ["CMD-SHELL", "pg_isready"] test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
interval: 10s interval: 10s
timeout: 5s timeout: 5s
retries: 5 retries: 5
@@ -24,14 +24,7 @@ services:
depends_on: depends_on:
db: db:
condition: service_healthy condition: service_healthy
command: > command: sh -c "python manage.py migrate --noinput && gunicorn config.wsgi:application --bind 0.0.0.0:8000 --workers 2 --timeout 60 --access-logfile - --error-logfile -"
sh -c "python manage.py migrate --noinput &&
gunicorn config.wsgi:application
--bind 0.0.0.0:8000
--workers 2
--timeout 60
--access-logfile -
--error-logfile -"
# ── Caddy (reverse proxy + HTTPS automatique) ─────────── # ── Caddy (reverse proxy + HTTPS automatique) ───────────
caddy: caddy:

View File

@@ -8,7 +8,7 @@ services:
- postgres_data:/var/lib/postgresql/data - postgres_data:/var/lib/postgresql/data
env_file: .env.prod env_file: .env.prod
healthcheck: healthcheck:
test: ["CMD-SHELL", "pg_isready"] test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
interval: 10s interval: 10s
timeout: 5s timeout: 5s
retries: 5 retries: 5