version: "3.9"

services:
  app:
    build:
      context: .
      args:
        - DEV=true
    ports:
      - "8000:8000"
    volumes:
      - ./app:/app
    command: >
      sh -c "python manage.py wait_for_db &&
              python manage.py migrate &&
              python manage.py runserver 0.0.0.0:8000"
    environment:
      - DB_HOST=db
      - DB_NAME=devdb
      - DB_USER=devuser
      - DB_PASS=devpass
    networks:
      - my_network
    depends_on:
      - db

  db:
    image: postgres:16.1-alpine
    volumes:
      - dev-db-data:/var/lib/postgesql/data
    networks:
      - my_network
    environment:
      - POSTGRES_DB=devdb
      - POSTGRES_USER=devuser
      - POSTGRES_PASSWORD=devpass

networks:
  my_network:
    driver: bridge

volumes:
  dev-db-data: