services:
  server:
    container_name: prefect-server
    image: prefecthq/prefect:3.0.9-python3.12
    restart: unless-stopped
    volumes:
      - ./server:/root/.prefect
      - /home/data/flows:/opt/prefect/flows
    entrypoint: ["prefect", "server", "start"]
    environment:
      - PREFECT_SERVER_API_HOST=0.0.0.0
      - PREFECT_API_DATABASE_CONNECTION_URL=postgresql+asyncpg://postgres:postgres@db:5432/prefect
    ports:
      - 4200:4200
    depends_on:
      - db

  nginx:
    image: nginx:latest
    container_name: nginx
    volumes:
      - ./nginx.conf:/etc/nginx/conf.d/default.conf
      - /home/emmanuel_rambeau/nginx/.htpasswd:/etc/nginx/.htpasswd:ro
      - ./certbot/conf/:/etc/letsencrypt/:ro
      - ./certbot/www/:/var/www/certbot/:ro
    ports:
      - "80:80"
      - "443:443"
    depends_on:
      - server

  certbot:
    image: certbot/certbot:latest
    volumes:
      - ./certbot/www/:/var/www/certbot/:rw
      - ./certbot/conf/:/etc/letsencrypt/:rw


  worker:
    container_name: prefect-worker
    image: prefecthq/prefect:3.0.9-python3.12
    restart: unless-stopped
    entrypoint: ["/opt/prefect/entrypoint.sh", "prefect", "worker", "start", "--pool", "default"]
    environment:
      - PREFECT_API_URL=http://server:4200/api
    depends_on:
      - server

  db:
    container_name: prefect-database
    image: postgres:16-bookworm
    restart: unless-stopped
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_DB=prefect
    expose:
      - 5432
    volumes:
      - ./postgres:/var/lib/postgresql/data