version: '3.8'

services:
  app:
    build: .
    depends_on:
      - db
    environment:
      - DB_HOST=db
      - DB_PORT=5432
      - DB_NAME=bdd_sophal
      - DB_USER=postgres
      - DB_PASSWORD=root
    ports:
      - "8080:8080"
    networks:
      - backend

  db:
    image: postgres:9.6
    environment:
      POSTGRES_DB: bdd_sophal
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: root
      POSTGRES_HOST_AUTH_METHOD: trust
    ports:
      - "5433:5432"
    networks:
      - backend
    volumes:
      - pgdata:/var/lib/postgresql/data
      - ./init-db:/docker-entrypoint-initdb.d


  pgadmin:
    image: dpage/pgadmin4
    environment:
      PGADMIN_DEFAULT_EMAIL: admin@admin.com
      PGADMIN_DEFAULT_PASSWORD: admin
    ports:
      - "5050:80"
    depends_on:
      - db
    networks:
      - backend

volumes:
  pgdata:

networks:
  backend:
