games_app/deploy/vps-gateway/docker-compose.yml
2026-10-31 19:42:34 +02:00

93 lines
2.8 KiB
YAML

# Passerelle reverse-proxy VPS — cohabitation Salon + Tloto (Prediqo)
# Un seul nginx écoute 80/443 ; le routage se fait par nom de domaine (SNI).
#
# Sur le VPS :
# 1. Arrêter le nginx qui occupe déjà 80/443 (ex. Salon) :
# cd Salon_... && docker compose stop nginx
# 2. Arrêter le nginx Prediqo (:9080/:9443) — les API/web restent up :
# cd games-project && docker stop prediqo_nginx_https
# 3. docker network create vps-edge # si absent
# 4. Configurer .env (ce dossier) puis :
# docker compose up -d
#
# Aucune modification du dépôt Salon requise.
services:
nginx:
image: nginx:1.27-alpine
container_name: vps_gateway_nginx
restart: unless-stopped
ports:
- "80:80"
- "443:443"
environment:
CERT_PRIMARY_DOMAIN: ${CERT_PRIMARY_DOMAIN}
SALON_DOMAIN1: ${SALON_DOMAIN1}
SALON_DOMAIN2: ${SALON_DOMAIN2:-}
PREDIQO_DOMAIN: ${PREDIQO_DOMAIN}
PREDIQO_DOMAIN_WWW: ${PREDIQO_DOMAIN_WWW:-www.${PREDIQO_DOMAIN}}
PREDIQO_CERT_NAME: ${PREDIQO_CERT_NAME:-${PREDIQO_DOMAIN}}
volumes:
# Certificats Salon (HTTP-01 / volume existant)
- letsencrypt:/etc/letsencrypt
- certbot-www:/var/www/certbot
# Certificat Tloto déjà obtenu (DNS) dans le projet games-project
- prediqo-letsencrypt:/etc/letsencrypt-prediqo:ro
- ./nginx/salon.conf.template:/etc/nginx/templates/salon.conf.template:ro
- ./nginx/prediqo.conf.template:/etc/nginx/templates/prediqo.conf.template:ro
command: >
/bin/sh -c "LAST='';
(while :; do
CUR=$$(cat /var/www/certbot/.cert-renewed 2>/dev/null || true);
if [ -n \"$$CUR\" ] && [ \"$$CUR\" != \"$$LAST\" ]; then
nginx -s reload || true;
LAST=\"$$CUR\";
fi;
sleep 60;
done) &
exec /docker-entrypoint.sh nginx -g 'daemon off;'"
networks:
- vps-edge
- salon-net
- prediqo-net
certbot-renew:
image: certbot/certbot:v2.11.0
restart: unless-stopped
volumes:
- letsencrypt:/etc/letsencrypt
- certbot-www:/var/www/certbot
entrypoint: /bin/sh
command: >
-c "trap exit TERM;
while :; do
certbot renew --webroot -w /var/www/certbot
--deploy-hook 'date +%s > /var/www/certbot/.cert-renewed'
--quiet;
sleep 12h;
done"
networks:
- vps-edge
networks:
vps-edge:
external: true
name: vps-edge
salon-net:
external: true
name: ${SALON_DOCKER_NETWORK}
prediqo-net:
external: true
name: ${PREDIQO_DOCKER_NETWORK}
volumes:
letsencrypt:
external: true
name: ${SALON_LETSENCRYPT_VOLUME}
certbot-www:
external: true
name: ${SALON_CERTBOT_WWW_VOLUME}
prediqo-letsencrypt:
external: true
name: ${PREDIQO_LETSENCRYPT_VOLUME}