services:
  db:
    image: postgres:15
    environment:
      POSTGRES_USER: user
      POSTGRES_PASSWORD: password
      POSTGRES_DB: mydatabase
    volumes:
      - postgres_data:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    networks:
      - app-network
  backup:
    build: ./backup
    volumes:
      - ./backups:/backups
      - /var/run/docker.sock:/var/run/docker.sock
    depends_on:
      - db
    networks:
      - app-network

  backend:
    build: ./backend
    volumes:
      - ./backend/app:/app/app
    environment:
      DATABASE_URL: postgresql://user:password@db:5432/mydatabase
    depends_on:
      - db
    ports:
      - "8000:8000"
    networks:
      - app-network

  frontend:
    build: 
      context: ./frontend
      args:
        VITE_API_URL: ${API_URL}

    ports:
      - "3000:80"
    depends_on:
      - backend
    networks:
      - app-network

volumes:
  postgres_data:

networks:
  app-network:
    driver: bridge
