services:
  # База данных
  db:
    image: postgres:15-alpine
    container_name: fishfish_db
    restart: always
    ports:
      - "5432:5432"
    environment:
      POSTGRES_USER: ${DB_USER}
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_DB: ${DB_NAME}
    volumes:
      - pg_data:/var/lib/postgresql/data

  # Бэкенд на Go
  backend:
    build: ./backend
    container_name: fishfish_backend
    restart: always
    ports:
      - "8081:8081"
    environment:
      - DB_DSN=host=${DB_HOST} user=${DB_USER} password=${DB_PASSWORD} dbname=${DB_NAME} port=${DB_PORT} sslmode=disable
    depends_on:
      - db
    volumes:
      - ./backend/uploads/:/root/uploads/

  # Фронтенд на React
  frontend:
    build: ./frontend
    container_name: fishfish_frontend
    restart: always
    ports:
      - "80:80"
    depends_on:
      - backend
    # Добавляем разрешение хоста для Vite прямо тут
    environment:
      - VITE_ALLOWED_HOSTS=fish.kkhome.ru

volumes:
  pg_data:
