diff --git a/.env.dev.example b/.env.dev.example index 0eec782..85aeff7 100644 --- a/.env.dev.example +++ b/.env.dev.example @@ -1,4 +1,5 @@ # 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 @@ -13,7 +14,13 @@ DJANGO_SETTINGS_MODULE=config.settings.prod ALLOWED_HOSTS=dev.jool-international.com 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_PORT=465 EMAIL_HOST_USER= diff --git a/Caddyfile.dev b/Caddyfile.dev index 0407f4b..9779a17 100644 --- a/Caddyfile.dev +++ b/Caddyfile.dev @@ -1,10 +1,8 @@ dev.jool-international.com { - # HTTPS automatique via Let's Encrypt (aucune config SSL nécessaire) - - # Fichiers statiques - handle /static/* { - root * /app + # Fichiers statiques Django + handle_path /static/* { + root * /app/staticfiles file_server } @@ -14,8 +12,8 @@ dev.jool-international.com { } # Autres fichiers media - handle /media/* { - root * /app + handle_path /media/* { + root * /app/media file_server } @@ -24,7 +22,6 @@ dev.jool-international.com { reverse_proxy web:8000 } - # Logs log { output stdout } diff --git a/Caddyfile.local b/Caddyfile.local new file mode 100644 index 0000000..36a53ff --- /dev/null +++ b/Caddyfile.local @@ -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 + } +} diff --git a/deploy-dev.sh b/deploy-dev.sh index cb1caf4..7f8dc4c 100755 --- a/deploy-dev.sh +++ b/deploy-dev.sh @@ -14,9 +14,14 @@ fi 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..." -$COMPOSE up -d --build +$COMPOSE build --no-cache +$COMPOSE up -d echo "" echo "✅ Déploiement terminé !" diff --git a/docker-compose.caddy-local.yml b/docker-compose.caddy-local.yml new file mode 100644 index 0000000..a1da4bd --- /dev/null +++ b/docker-compose.caddy-local.yml @@ -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: diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 5b1569c..dc6686f 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -8,7 +8,7 @@ services: - postgres_data_dev:/var/lib/postgresql/data env_file: .env.dev healthcheck: - test: ["CMD-SHELL", "pg_isready"] + test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"] interval: 10s timeout: 5s retries: 5 @@ -24,14 +24,7 @@ services: 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 -" + 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 (reverse proxy + HTTPS automatique) ─────────── caddy: diff --git a/docker-compose.yml b/docker-compose.yml index b4dcd60..af81312 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: - postgres_data:/var/lib/postgresql/data env_file: .env.prod healthcheck: - test: ["CMD-SHELL", "pg_isready"] + test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"] interval: 10s timeout: 5s retries: 5