serveur caddy
This commit is contained in:
31
Caddyfile.dev
Normal file
31
Caddyfile.dev
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
dev.jool-international.com {
|
||||||
|
|
||||||
|
# HTTPS automatique via Let's Encrypt (aucune config SSL nécessaire)
|
||||||
|
|
||||||
|
# Fichiers statiques
|
||||||
|
handle /static/* {
|
||||||
|
root * /app
|
||||||
|
file_server
|
||||||
|
}
|
||||||
|
|
||||||
|
# CVs : jamais accessibles publiquement
|
||||||
|
handle /media/careers/cvs/* {
|
||||||
|
respond 404
|
||||||
|
}
|
||||||
|
|
||||||
|
# Autres fichiers media
|
||||||
|
handle /media/* {
|
||||||
|
root * /app
|
||||||
|
file_server
|
||||||
|
}
|
||||||
|
|
||||||
|
# Application Django
|
||||||
|
handle {
|
||||||
|
reverse_proxy web:8000
|
||||||
|
}
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
log {
|
||||||
|
output stdout
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Déploiement dev.jool-international.com
|
# Déploiement dev.jool-international.com (Caddy)
|
||||||
# Usage : bash deploy-dev.sh
|
# Usage : bash deploy-dev.sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
DOMAIN="dev.jool-international.com"
|
|
||||||
EMAIL="info@jool-int.com"
|
|
||||||
COMPOSE="docker compose -f docker-compose.dev.yml"
|
COMPOSE="docker compose -f docker-compose.dev.yml"
|
||||||
|
|
||||||
# ── 1. Vérifier .env.dev ─────────────────────────────────
|
# ── 1. Vérifier .env.dev ─────────────────────────────────
|
||||||
@@ -16,30 +14,13 @@ fi
|
|||||||
|
|
||||||
echo "✅ .env.dev trouvé"
|
echo "✅ .env.dev trouvé"
|
||||||
|
|
||||||
# ── 2. Démarrer avec nginx HTTP only ─────────────────────
|
# ── 2. Build et démarrage ─────────────────────────────────
|
||||||
echo "🚀 Démarrage des conteneurs (HTTP only)..."
|
echo "🚀 Build et démarrage des conteneurs..."
|
||||||
$COMPOSE up -d --build
|
$COMPOSE up -d --build
|
||||||
|
|
||||||
# Attendre que nginx soit prêt
|
|
||||||
sleep 5
|
|
||||||
|
|
||||||
# ── 3. Obtenir le certificat SSL ─────────────────────────
|
|
||||||
echo "🔒 Obtention du certificat SSL pour $DOMAIN..."
|
|
||||||
$COMPOSE run --rm certbot certonly \
|
|
||||||
--webroot \
|
|
||||||
--webroot-path=/var/www/certbot \
|
|
||||||
-d "$DOMAIN" \
|
|
||||||
--email "$EMAIL" \
|
|
||||||
--agree-tos \
|
|
||||||
--no-eff-email
|
|
||||||
|
|
||||||
# ── 4. Passer à la config HTTPS ──────────────────────────
|
|
||||||
echo "🔄 Activation de la config HTTPS..."
|
|
||||||
sed -i 's|nginx.dev-init.conf|nginx.dev.conf|g' docker-compose.dev.yml
|
|
||||||
|
|
||||||
# Redémarrer nginx avec la config HTTPS
|
|
||||||
$COMPOSE up -d nginx
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "✅ Déploiement terminé !"
|
echo "✅ Déploiement terminé !"
|
||||||
echo " Site disponible sur https://$DOMAIN"
|
echo " Caddy obtient le certificat SSL automatiquement."
|
||||||
|
echo " Site disponible sur https://dev.jool-international.com"
|
||||||
|
echo ""
|
||||||
|
echo " Logs : docker compose -f docker-compose.dev.yml logs -f"
|
||||||
|
|||||||
@@ -26,36 +26,33 @@ services:
|
|||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
command: >
|
command: >
|
||||||
sh -c "python manage.py migrate --noinput &&
|
sh -c "python manage.py migrate --noinput &&
|
||||||
gunicorn config.wsgi:application --bind 0.0.0.0:8000 --workers 2
|
gunicorn config.wsgi:application
|
||||||
--timeout 60 --access-logfile - --error-logfile -"
|
--bind 0.0.0.0:8000
|
||||||
|
--workers 2
|
||||||
|
--timeout 60
|
||||||
|
--access-logfile -
|
||||||
|
--error-logfile -"
|
||||||
|
|
||||||
# ── Nginx (reverse proxy + static files) ───────────────
|
# ── Caddy (reverse proxy + HTTPS automatique) ───────────
|
||||||
nginx:
|
caddy:
|
||||||
image: nginx:alpine
|
image: caddy:2-alpine
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
- "443:443"
|
- "443:443"
|
||||||
|
- "443:443/udp"
|
||||||
volumes:
|
volumes:
|
||||||
- ./nginx/nginx.dev-init.conf:/etc/nginx/conf.d/default.conf:ro
|
- ./Caddyfile.dev:/etc/caddy/Caddyfile:ro
|
||||||
- static_volume_dev:/app/staticfiles:ro
|
- static_volume_dev:/app/staticfiles:ro
|
||||||
- media_volume_dev:/app/media:ro
|
- media_volume_dev:/app/media:ro
|
||||||
- certbot_www_dev:/var/www/certbot:ro
|
- caddy_data_dev:/data
|
||||||
- certbot_certs_dev:/etc/letsencrypt:ro
|
- caddy_config_dev:/config
|
||||||
depends_on:
|
depends_on:
|
||||||
- web
|
- web
|
||||||
|
|
||||||
# ── Certbot (SSL Let's Encrypt) ─────────────────────────
|
|
||||||
certbot:
|
|
||||||
image: certbot/certbot
|
|
||||||
volumes:
|
|
||||||
- certbot_www_dev:/var/www/certbot
|
|
||||||
- certbot_certs_dev:/etc/letsencrypt
|
|
||||||
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres_data_dev:
|
postgres_data_dev:
|
||||||
static_volume_dev:
|
static_volume_dev:
|
||||||
media_volume_dev:
|
media_volume_dev:
|
||||||
certbot_www_dev:
|
caddy_data_dev:
|
||||||
certbot_certs_dev:
|
caddy_config_dev:
|
||||||
|
|||||||
Reference in New Issue
Block a user