services:
  postgres:
    image: postgres:15-alpine
    container_name: imobiliaria-db
    restart: unless-stopped
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: imobiliaria
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - imobiliaria-network
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 10s
      timeout: 5s
      retries: 5

  backend:
    image: reinodigital/imobiliaria-backend:latest
    container_name: imobiliaria-api
    restart: unless-stopped
    environment:
      NODE_ENV: production
      DATABASE_URL: postgresql://postgres:${POSTGRES_PASSWORD}@postgres:5432/imobiliaria
      JWT_SECRET: ${JWT_SECRET}
      PORT: 3000
    ports:
      - "3000:3000"
    volumes:
      - ./uploads:/app/uploads
    depends_on:
      postgres:
        condition: service_healthy
    networks:
      - imobiliaria-network

  frontend:
    image: reinodigital/imobiliaria-frontend:latest
    container_name: imobiliaria-frontend
    restart: unless-stopped
    ports:
      - "80:80"
    depends_on:
      - backend
    networks:
      - imobiliaria-network

volumes:
  postgres_data:

networks:
  imobiliaria-network:
    driver: bridge
