version: "3.9"
services:
  db:
    image: postgres:16.3-bullseye
    restart: always
    container_name: allegra-${CONTEXT}-db
    volumes:
      - ${ALLEGRA_HOME}/dbdata:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=allegra-${CONTEXT}
      - POSTGRES_USER=allegra
      - POSTGRES_PASSWORD=tissi189
    ports:
      - "8001:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U allegra -d allegra-${CONTEXT}"]
      interval: 10s
      timeout: 5s
      retries: 2
  allegra:
    image: allegrapm/core:8.1.3
    restart: always
    container_name: allegra-${CONTEXT}    
    volumes: 
      - ${ALLEGRA_HOME}:/home/allegra
    environment:
      JAVA_OPTS: ${JAVA_OPTS}
      CONTEXT: ${CONTEXT}
      DB_URL: jdbc:postgresql://db/allegra-${CONTEXT}
      DB_USER: allegra
      DB_PASSWD: tissi189
    ports:
      - "${HTTP_PORT}:8080"
      - "8089:8009"
    depends_on:
      db:
        condition: service_healthy