services:
  certbot:
    image: certbot/certbot
    container_name: certbot
    restart: unless-stopped
    ports:
      - "80:80" # Only listen on HTTP for Let's Encrypt challenges
    volumes:
      - /mnt/fileshares/pixilime/pixi-certs:/etc/letsencrypt  # SSL Certificates
      - /mnt/fileshares/dockers/pixi-cerbot:/var/www/certbot  # Webroot for challenges
      - /mnt/fileshares/pixilime/pixi-logs/logs/certbot:/var/log/letsencrypt  # Logs
    entrypoint: >
      sh -c "
      echo 'Starting Certbot Web Server...'; 
      cd /var/www/certbot && python3 -m http.server 80 --bind 0.0.0.0 --directory . & 
      trap exit TERM; 
      while :; do 
        sleep 12h & wait $${!}; 
        certbot renew --webroot -w /var/www/certbot --quiet; 
      done"
    networks:
      - default  # Use Docker's default network
