services:
  postgres:
    image: postgres:15-alpine
    container_name: socka_properties_db
    environment:
      POSTGRES_USER: ${POSTGRES_USER:-socka}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-change-me-in-env}
      POSTGRES_DB: ${POSTGRES_DB:-socka_properties}
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-socka} -d ${POSTGRES_DB:-socka_properties}"]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - socka_network
    restart: unless-stopped

  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    container_name: socka_properties_backend
    environment:
      DATABASE_URL: postgresql://${POSTGRES_USER:-socka}:${POSTGRES_PASSWORD:-change-me-in-env}@postgres:5432/${POSTGRES_DB:-socka_properties}
      POSTGRES_HOST: postgres
      POSTGRES_USER: ${POSTGRES_USER:-socka}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-change-me-in-env}
      POSTGRES_DB: ${POSTGRES_DB:-socka_properties}
      POSTGRES_PORT: 5432
      SECRET_KEY: ${SECRET_KEY:-change-me-in-env}
      ALGORITHM: HS256
    ports:
      - "8000:8000"
    depends_on:
      postgres:
        condition: service_healthy
    volumes:
      - uploads_data:/app/uploads
    command: sh /app/start_prod.sh
    networks:
      - socka_network
    restart: unless-stopped

  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile.prod
      args:
        NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-http://localhost:8000}
    container_name: socka_properties_frontend
    environment:
      - DOCKER_ENV=true
      - NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-http://localhost:8000}
    ports:
      - "3000:3000"
    depends_on:
      - backend
    networks:
      - socka_network
    restart: unless-stopped

networks:
  socka_network:
    driver: bridge

volumes:
  postgres_data:
  uploads_data:



