services:
  db:
    image: timescale/timescaledb-ha:pg16
    restart: always
    environment:
      - POSTGRES_USER=${DB_USER}
      - POSTGRES_PASSWORD=${DB_PASSWORD}
      - POSTGRES_DB=harvester
    networks:
      - default 
    volumes:
      - {{ service_directory }}/data/db:/var/lib/postgresql/data
    ports:
      - '5432:5432'
      
  app:
    image: git.captica.de/captica/de.captica.expert.connect-device-harvester:latest  
    environment:
      SPRING_APPLICATION_JSON: '{
        "USER_UID": "{{ service_user_id }}",
        "USER_GID": "{{ service_group_id }}",
        "spring.datasource.url"  : "jdbc:postgresql://db:5432/harvester",
        "spring.datasource.username" : "${DB_USER}",
        "spring.datasource.password" : "${DB_PASSWORD}",
        "connectdeviceharvester.knxGateway.ip" : "192.168.150.69",
        "connectdeviceharvester.knxGateway.port" : "3671",
        "connectdeviceharvester.knxGateway.useNat" : "true",
        "connectdeviceharvester.localPort" : "3671"
      }'      
    restart: always
    volumes:
      - {{ service_directory }}/data/appdata:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    networks:
      - default

networks:
  default:
    ipam:
      driver: default
      config:
        - subnet: 172.2.0.0/16
          gateway: 172.2.0.1