version: '3.9'
services:
  postgres_16: &pg_base
    image: postgis/postgis:16-3.4
    environment:
      POSTGRES_PASSWORD: admin
      POSTGRES_USER: password
    ports:
      - 5433:5432
    networks:
      - development
    volumes:
      - ./tmp/db_16:/var/lib/postgresql/data
      - shared_data:/var/shared

  postgres_tests:
    <<: *pg_base
    ports:
      - 5434:5432
    volumes:
      - pg_tests:/var/lib/postgresql/data

  postgres_16_2:
    <<: *pg_base
    ports:
      - 5435:5432
    volumes:
      - ./tmp/db_16_2:/var/lib/postgresql/data
      - shared_data:/var/shared

  pgadmin4:
    image: 'dpage/pgadmin4:8.12.0'
    environment:
      MASTER_PASSWORD_REQUIRED: 'false'
      PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-admin@pgadmin.org}
      PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
      PGADMIN_LISTEN_ADDRESS: 0.0.0.0
      PGADMIN_LISTEN_PORT: 8080
    volumes:
      - ./tmp/pgadmin4:/var/lib/pgadmin
      - shared_data:/var/shared
    networks:
      - development
    ports:
      - 8082:8080
    tty: true

networks:
  development:
    driver: bridge

volumes:
  pg_tests:
    driver_opts:
      type: tmpfs
      device: tmpfs
  shared_data:
