
services:
  db:
    image: postgres:15
    environment:
      POSTGRES_DB: "${DB_NAME}"
      POSTGRES_USER: "${DB_USER}"
      POSTGRES_PASSWORD: "${DB_PASSWORD}"
    volumes:
      - db_data:/var/lib/postgresql/data/
    ports:
      - "5432:5432"
    networks:
      - app_network

  # duplicati:
  #   image: duplicati/duplicati:2.1.0.119

  #   ports:
  #     - "8200:8200"
    
  #   volumes:
  #     - ./duplicati_config:/config
  #     - ./duplicati_backups:/backups
  #     - db_data:/source_postgres_data:ro

    
  django_app:
    build:
      context: ./ 
      dockerfile: Dockerfile
    ports:
      - "8000:8000"

    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/"]
      interval: 5m
      timeout: 3s
      retries: 3
    restart: on-failure

    volumes:
      - static_volume:/app/gestaoRaul/static
    environment:
      DB_ENGINE: "${DB_ENGINE}"
      DB_HOST: "${DB_HOST}"
      DB_PORT: "${DB_PORT}"
      DB_NAME: "${DB_NAME}"
      DB_USER: "${DB_USER}"
      DB_PASSWORD: "${DB_PASSWORD}"
      DEBUG: "False"
      ALLOWED_HOSTS: "rrbec.local.com, 0.0.0.0, 127.0.0.1, 192.168.0.150, django_app"

    networks:
      - app_network

  nginx_server:
    build:
      context: ./NginxServer
      dockerfile: Dockerfile
    volumes:
      - static_volume:/app/gestaoRaul/static
    ports:
      - "80:80"
    # depends_on:
    #   - django_app
    networks:
      - app_network

  websocket_server:
    build:
      context: ./WebSocketServer
      dockerfile: Dockerfile
    ports:
      - "8765:8765"
    restart: on-failure
    networks:
      - app_network

volumes:
  static_volume:
  db_data:

networks:
  app_network:
    driver: bridge