version: '3.3'

services:

  letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    container_name: ${COMPOSE_PROJECT_NAME}_letsencrypt
    volumes:
      - vhost:/etc/nginx/vhost.d
      - html:/usr/share/nginx/html
      - dhparam:/etc/nginx/dhparam:ro
      - certs:/etc/nginx/certs
      - acme:/etc/acme.sh
      - /var/run/docker.sock:/var/run/docker.sock:ro
    environment:
      - NGINX_PROXY_CONTAINER=${COMPOSE_PROJECT_NAME}_nginx-proxy
    restart: always
    depends_on:
      - nginx-proxy
    networks:
      - api-rrhh

  nginx-proxy:
    container_name: ${COMPOSE_PROJECT_NAME}_nginx-proxy
    image: jwilder/nginx-proxy
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - conf:/etc/nginx/conf.d
      - vhost:/etc/nginx/vhost.d
      - html:/usr/share/nginx/html
      - dhparam:/etc/nginx/dhparam
      - certs:/etc/nginx/certs:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
    networks:
      - api-rrhh

  nginx:
    image: nginx:1.21.0-alpine
    container_name: ${COMPOSE_PROJECT_NAME}_nginx
    environment:
      - VIRTUAL_HOST=${VIRTUAL_HOST}
      - VIRTUAL_PORT=80
      - LETSENCRYPT_HOST=${LETSENCRYPT_HOST}
      - LETSENCRYPT_EMAIL=${SERVICE_EMAIL}
    volumes:
      - ${PROJECT_RRHH}:/var/www/html
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - php
      - nginx-proxy
    networks:
      - api-rrhh

  php:
    build:
      context: .
      dockerfile: php.Dockerfile
    container_name: ${COMPOSE_PROJECT_NAME}_php
    volumes:
      - ${PROJECT_RRHH}:/var/www/html
    ports:
      - 9000:80
    networks:
      - api-rrhh

networks:
  api-rrhh:

volumes:
  conf:
  vhost:
  html:
  dhparam:
  certs:
  acme:
