version: '3'

services:
  # Web server - serves your website content
  web:
    image: nginx:alpine
    ports:
      - "80:80"  # Only exposed locally, not to the internet
    volumes:
      - ./website:/usr/share/nginx/html  # Your website files go in the "website" folder
      - ./nginx.conf:/etc/nginx/conf.d/default.conf  # Nginx configuration
    restart: always
    networks:
      - web_network

  # Cloudflare tunnel service - connects your website to the internet securely
  cloudflared:
    image: cloudflare/cloudflared:latest
    command: tunnel --config /etc/cloudflared/config.yml run
    volumes:
      - ./cloudflared-config.yml:/etc/cloudflared/config.yml:ro  # Your tunnel configuration
      - ~/.cloudflared:/root/.cloudflared:ro  # Your tunnel credentials
    restart: always
    depends_on:
      - web  # Ensures web service starts first
    networks:
      - web_network

# Network used by both services to communicate
networks:
  web_network:
    driver: bridge
