version: "3.9"

services:
  # postgres-db:
  #    image: kartoza/postgis:12.0
  #    ports:
  #       - 5432:5432
  #    volumes:
  #       - postgres_data:/var/lib/postgresql
  #       - ./custom-postgresql.conf:/etc/postgresql/12/main/postgresql.conf
  #    environment:
  #       - POSTGRES_USER=${POSTGRES_USER}
  #       - POSTGRES_PASS=${POSTGRES_PASS}
  #       - POSTGRES_DBNAME=${POSTGRES_DBNAME}
  #       - POSTGRES_MAX_CONNECTIONS=600

  #    restart: "on-failure"
  #    networks:
  #       - rog-api

  api:
    build:
      context: .
      dockerfile: Dockerfile.gdal
    command: python3 manage.py runserver 0.0.0.0:8100
    volumes:
      - .:/app
    ports:
      - 8100:8100
    env_file:
      - .env
    restart: "on-failure"
    #  depends_on:
    #    - postgres-db
    networks:
      - rog-api
    #entrypoint: ["/app/wait-for.sh", "postgres-db:5432", "--", ""]
    #command: python3 manage.py runserver 0.0.0.0:8100

  supervisor-web:
    build:
      context: .
      dockerfile: Dockerfile.supervisor
    volumes:
      - type: bind
        source: /etc/letsencrypt
        target: /etc/nginx/ssl
        read_only: true
      - type: bind
        source: ./supervisor/html
        target: /usr/share/nginx/html
        read_only: true
      - type: bind
        source: ./supervisor/nginx/default.conf
        target: /etc/nginx/conf.d/default.conf
        read_only: true
      - type: volume
        source: static_volume
        target: /app/static
        read_only: true
      - type: volume
        source: nginx_logs
        target: /var/log/nginx
    ports:
      - "80:80"
    depends_on:
      - api
    networks:
      - rog-api
    restart: always


networks:
  rog-api:
    driver: bridge

volumes:
  postgres_data:
  geoserver-data:
  static_volume:
  nginx_logs:
