services:

  cliente:
    user: "1000:1000"
    build:
      args:
        user: sammy
        uid: 1000
      context: ./php/.
      dockerfile: Dockerfile
    image: cliente-sicoin_api-backend:latest
    container_name: cliente-sicoin_api-backend
    restart: unless-stopped
    working_dir: /var/www/
    volumes:
      - ./cliente:/var/www
    networks:
      - rede
      
  realtime:
    image: node:20-alpine
    container_name: realtime-sicoin_api-backend
    restart: unless-stopped
    working_dir: /app
    volumes:
      - ./realtime:/app
    command: sh -c "npm install && node src/server.js"
    depends_on:
      - redis
    ports:
      - "3001:3001"
    networks:
      - rede

  nginx:
    image: nginx:alpine
    container_name: nginx-sicoin_api-backend
    restart: unless-stopped
    ports:
      - 8081:80
    volumes:
      - ./cliente:/var/www
      - ./nginx:/etc/nginx/conf.d/
    networks:
      - rede

  redis:
    image: redis:7-alpine
    container_name: redis-sicoin_api-backend
    restart: unless-stopped
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    networks:
      - rede

  loki:
    image: grafana/loki:3.0.0
    container_name: loki-sicoin_api-backend
    restart: unless-stopped
    command: -config.file=/etc/loki/config.yml
    volumes:
      - ./loki:/etc/loki
      - loki_data:/loki
    ports:
      - "3100:3100"
    networks:
      - rede

  promtail:
    image: grafana/promtail:3.0.0
    container_name: promtail-sicoin_api-backend
    restart: unless-stopped
    command: -config.file=/etc/promtail/config.yml
    volumes:
      - ./promtail:/etc/promtail
      - ./cliente/storage/logs:/var/log/laravel
    depends_on:
      - loki
    networks:
      - rede

  grafana:
    image: grafana/grafana:11.3.0
    container_name: grafana-sicoin_api-backend
    restart: unless-stopped
    environment:
      GF_SECURITY_ADMIN_USER: admin
      GF_SECURITY_ADMIN_PASSWORD: admin
    ports:
      - "3030:3000"
    volumes:
      - grafana_data:/var/lib/grafana
    depends_on:
      - loki
    networks:
      - rede

networks:
  rede:
    driver: bridge

volumes:
  loki_data:
  grafana_data:
  redis_data:
