version: "2"

services:
  nginx:
    build: ./nginx
    image: evgeniy-khyst/nginx
    env_file:
      - ./config.env
    volumes:
      - nginx_conf:/etc/nginx/sites
      - letsencrypt_certs:/etc/letsencrypt
      - certbot_acme_challenge:/var/www/certbot
      - ./vhosts:/etc/nginx/vhosts
      - ./html:/var/www/html
    ports:
      - "80:80"
      - "443:443"
    restart: unless-stopped

  certbot:
    build: ./certbot
    image: evgeniy-khyst/certbot
    env_file:
      - ./config.env
    volumes:
      - letsencrypt_certs:/etc/letsencrypt
      - certbot_acme_challenge:/var/www/certbot

  cron:
    build: ./cron
    image: evgeniy-khyst/cron
    environment:
      COMPOSE_PROJECT_NAME: "${COMPOSE_PROJECT_NAME}"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./:/workdir:ro
    restart: unless-stopped

volumes:
  nginx_conf:
    external: true
  letsencrypt_certs:
    external: true
  certbot_acme_challenge:
