# ------------------------------------------------------------------------------
# Copyright (C) 2022 European Spallation Source ERIC.
# ------------------------------------------------------------------------------

version: '3.7'
services:
  naming:
    build: ./
    ports:
      - "8080:8083"
    depends_on:
      postgres: 
        condition: service_healthy
    command: "java -jar /naming/naming-backend-0.0.1-SNAPSHOT.jar"
  
  postgres:
    image: "postgres:9.6.7"
    ports:
      - "5432:5432"
    environment:
      POSTGRES_DB: discs_names
      POSTGRES_USER: discs_names
      POSTGRES_PASSWORD: discs_names
      PGDATA: /var/lib/postgresql/data/pgdata
    healthcheck: 
      test: ["CMD-SHELL", "pg_isready -U discs_names"]
      interval: 10s
      timeout: 5s
      retries: 10    
    volumes:
      - ./src/test/resources/db/schema_migration/V1__Initial.sql:/docker-entrypoint-initdb.d/V1__Initial.sql
      - ./src/test/resources/db/schema_migration/V2__Commit_Msg_to_Device.sql:/docker-entrypoint-initdb.d/V2__Commit_Msg_to_Device.sql
      - ./src/test/resources/db/schema_migration/V3__Notification_CC_List.sql:/docker-entrypoint-initdb.d/V3__Notification_CC_List.sql
      - ./src/test/resources/db/schema_migration/V4__Schema_data_migration.sql:/docker-entrypoint-initdb.d/V4__Schema_data_migration.sql

volumes:
  naming-data:
