version: "3.8"

services:
  fastapi:
    build: .
    container_name: fastapi_app
    restart: "no"
    depends_on:
      - db
      - mailpit
    env_file:
      - .env
    ports:
      - "8000:8000"
    volumes:
      - .:/app
    networks:
      - mynetwork
    # command: ["fastapi", "dev", "--app", "app.main:app"]  # Se asegura de que se use fastapi dev
    command: ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]

  db:
    image: postgres:17.2
    container_name: postgres_db
    restart: "no"
    environment:
      POSTGRES_USER: admin
      POSTGRES_PASSWORD: admin
      POSTGRES_DB: dev_barterflip
    ports:
      - "5434:5432"
    networks:
      - mynetwork
    volumes:
      - postgres_data:/var/lib/postgresql/data

  mailpit:
    image: axllent/mailpit
    container_name: mailpit_service
    restart: "no"
    ports:
      - "8030:8025"
      - "1030:1025"
    networks:
      - mynetwork

networks:
  mynetwork:
    driver: bridge

volumes:
  postgres_data: