volumes:
  pg_data:

services:
  postgres:
   image: postgres:17
   environment:
    - POSTGRES_DB=${DATABASE_NAME}
    - POSTGRES_USER=${DATABASE_USER}
    - POSTGRES_PASSWORD=${DATABASE_PASSWORD}
   ports:
    - "5432:5432"
   volumes:
    - pg_data:/var/lib/postgresql/data

  backend:
    build:
      target: dev
    extends:
      file: docker-compose.build.yml
      service: backend
    volumes:
      - ./services/backend:/app
    depends_on:
      - postgres
    ports:
      - "8000:8000"
    environment:
      - DJANGO_ENV=${DJANGO_ENV}
      - DATABASE_HOST=postgres
      - DATABASE_URL=psql://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}

  frontend:
    build:
      target: dev
    extends:
      file: docker-compose.build.yml
      service: frontend
    tmpfs:
      - /tmp
    ports:
      - "3000:3000"
    volumes:
      - ./services/frontend:/app
    environment:
      - DJANGO_ENV=${DJANGO_ENV}
      - DATABASE_NAME=${DATABASE_NAME}
      - DATABASE_USER=${DATABASE_USER}
      - DATABASE_PASSWORD=${DATABASE_PASSWORD}
      - DATABASE_HOST=${DATABASE_HOST}
      - DATABASE_PORT=${DATABASE_PORT}
