version: '3.8'

services:
  db:
    image: postgres:latest
    container_name: family_db
    networks:
      - default
    restart: always 
    environment:
      POSTGRES_DB: my_database
      POSTGRES_USER: my_user
      POSTGRES_PASSWORD: my_password
    ports:
      - "5432:5432"
    volumes:
      - db_vol:/var/lib/postgresql/
  pgadmin:
    image: dpage/pgadmin4:latest
    restart: always
    container_name: my_pgadmin
    environment:
      PGADMIN_DEFAULT_EMAIL: admin@example.com
      PGADMIN_DEFAULT_PASSWORD: admin_password
      PGADMIN_LISTEN_PORT: 5050
    ports:
      - "5050:5050"
    depends_on:
      - db
    volumes:
      - pgadmin:/var/lib/pgadmin/
  backend:
    container_name: server
    networks:
      - default
    depends_on:
      - db
    build:
      context: ./backend
      dockerfile: dockerfile
    ports:
      - "8080:8080"

networks:
  default:

volumes:
  db_vol:
  pgadmin:

