version: '2'

services:
  nginx-proxy:
    image: nginx
    container_name: nginx-proxy
    ports:
      - "80:80"
      - "443:443"
    restart: always
    volumes:
      - "./vhost.d:/etc/nginx/vhost.d"
      - "./conf.d:/etc/nginx/conf.d"
      - "./html:/usr/share/nginx/html"
      - "./htpasswd:/etc/nginx/htpasswd"
      - "./certs:/etc/nginx/certs"
    networks:
      - nginxproxy
    #network_mode: host
   
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "10"

  dockergen:
    image: jwilder/docker-gen
    container_name: nginx-proxy-gen
    restart: always
    command: -notify-sighup nginx-proxy -watch /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
    volumes_from:
      - nginx-proxy
    environment:
      - HSTS=off
      - RESOLVERS=8.8.8.8
      - ENABLE_HTTP3=true
    volumes:
      - "/var/run/docker.sock:/tmp/docker.sock:ro"
      - "./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl"
    networks:
      - nginxproxy
    logging:
      driver: "json-file"

  letsencrypt-nginx-proxy-companion:
    container_name: nginx-proxy-letsencrypt
    image: jrcs/letsencrypt-nginx-proxy-companion
    restart: always
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
    volumes_from:
      - nginx-proxy
    environment:
      - NGINX_PROXY_CONTAINER=nginx-proxy
      - NGINX_DOCKER_GEN_CONTAINER=nginx-proxy-gen
    networks:
      - nginxproxy
    logging:
      driver: "json-file"

# this creates a network we can connect to in other docker-compose 
networks:
  nginxproxy:                                                                                                            
