
services:
  postgres:
    container_name: eglpm_postgres
    image: postgres:17.3
    volumes:
      - postgres_data:/var/lib/postgresql/data
    ports:
      - "9095:5432"
    environment:
      POSTGRES_DB: ${POSTGRES_EGL_PM_DB}
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    networks:
      - egl_pm_network
  
  pgadmin:
    image: dpage/pgadmin4
    container_name: eglpm_pgadmin
    restart: unless-stopped
    ports:
      - "9094:80"
    networks:
      - egl_pm_network
    depends_on:
      - postgres
    links:
      - postgres
    environment:
      PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL}
      PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD}
      PGADMIN_CONFIG_SERVER_MODE: 'False'
    volumes:
      - egl_pm_pgadmin:/var/lib/pgadmin

  keycloak:
    container_name: eglpm_keycloak
    image: quay.io/keycloak/keycloak:23.0.6
    # build:
    #   context: .
    #   dockerfile: Dockerfile
    command: start
    environment:
      KC_HOSTNAME: 38.242.223.54
      KC_HOSTNAME_PORT: 9092
      KC_HOSTNAME_STRICT_BACKCHANNEL: false
      KC_HTTP_ENABLED: true
      KC_HOSTNAME_STRICT_HTTPS: false
      KC_HEALTH_ENABLED: true
      KEYCLOAK_ADMIN: ${KEYCLOAK_ADMIN}
      KEYCLOAK_ADMIN_PASSWORD: ${KEYCLOAK_ADMIN_PASSWORD}
      KC_DB: postgres
      KC_DB_URL: jdbc:postgresql://postgres/${POSTGRES_EGL_PM_DB}
      KC_DB_USERNAME: ${POSTGRES_USER}
      KC_DB_PASSWORD: ${POSTGRES_PASSWORD}
    ports:
      - 9092:8080
    restart: always
    depends_on:
      - postgres
    networks:
      - egl_pm_network
    volumes:
      - keycloak:/var/lib/keycloak/data
      
  rabbitmq:
    container_name: eglpm_rabbitmq-new
    image: rabbitmq:3-management
    ports:
      - "5672:5672"
      - "15672:15672"
    environment:
      RABBITMQ_DEFAULT_USER: ${RABBITMQ_USERNAME} # RabbitMQ username
      RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASSWORD} # RabbitMQ password
      
  spring-app:
    container_name: eglpm_backend
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "9091:8080"
    networks:
      - egl_pm_network
    depends_on:
      - postgres
      - keycloak
      - rabbitmq
    links:
      - "postgres:eglpm_postgres"
    environment:
      - SPRING_DATASOURCE_URL=jdbc:postgresql://postgres/${POSTGRES_EGL_PM_DB}
      - SPRING_DATASOURCE_USERNAME=${POSTGRES_USER}
      - SPRING_DATASOURCE_PASSWORD=${POSTGRES_PASSWORD}    

volumes:
  postgres_data:
    driver: local
  egl_pm_pgadmin:
    driver: local
  keycloak:
    driver: local

networks:
  egl_pm_network:
    driver: bridge

# version: "3.8"
# services:
#   postgres_db:
#     image: postgres
#     container_name: egl_pm_pgdb
#     restart: unless-stopped
#     ports:
#       - "9093:5432"
#     environment:
#       POSTGRES_USER: egl
#       POSTGRES_PASSWORD: Eg89G8$p9$u&m02
#       POSTGRES_DB: egl_pm_db
#       PGDATA: /data/postgres
#     volumes:
#       - egl_pm_postgres:/data/postgres
#     networks:
#       - egl_pm

#   pgadmin:
#     image: dpage/pgadmin4
#     container_name: egl_pm_pgadmin4
#     restart: unless-stopped
#     ports:
#       - "9094:80"
#     networks:
#       - egl_pm
#     environment:
#       PGADMIN_DEFAULT_EMAIL: alainbakole55@gmail.com
#       PGADMIN_DEFAULT_PASSWORD: E7a8g9K7G8$9u&02
#       PGADMIN_CONFIG_SERVER_MODE: 'False'
#     volumes:
#       - egl_pm_pgadmin:/var/lib/pgadmin
  
#   keycloak:
#     image: keycloak/keycloak:22.0.1
#     container_name: keycloak
#     environment:
#       KEYCLOAK_ADMIN: egl
#       KEYCLOAK_ADMIN_PASSWORD: E78g9KG8$p9u&m02
#     ports:
#       - "9092:8080"
#     networks:
#       - egl_pm
#     restart: always
#     command: start
#     volumes:
#       - keycloak:/var/lib/keycloak/data

  # spring-app:
  #   container_name: egl_pm_bkd
  #   build: .
    # ports:
    #   - "9091:8080"
    # depends_on:
    #   - postgres_db
    # environment:
    #   - SPRING_DATASOURCE_URL=jdbc:postgresql://postgres:9093/egl_pm_db
    #   - SPRING_DATASOURCE_USERNAME=egl
    #   - SPRING_DATASOURCE_PASSWORD=Eg89G8$p9$u&m02

  # angular-app:
  #   container_name: egl_pm_ftd
  #   build: ./angular

# networks:
#   egl_pm:
#     driver: bridge

# volumes:
#   egl_pm_postgres:
#   egl_pm_pgadmin:
#   keycloak:

  