services:
  portainer:
    image: portainer/portainer-ce:latest
    container_name: portainer
    restart: unless-stopped
    ports:
      - "9000:9000"
      - "9443:9443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer_data:/data
    networks:
      - evolution_net

  evolution-api:
    image: evoapicloud/evolution-api:v2.3.6
    container_name: evolution_api
    restart: unless-stopped
    env_file:
      - .env
    depends_on:
      - redis-evolution
      - postgres-evolution
    ports:
      - "8080:8080"
    volumes:
      - evolution_instances:/evolution/instances
    networks:
      - evolution_net

  postgres-evolution:
    image: postgres:15
    container_name: postgres_evolution
    restart: unless-stopped
    command:
      - "postgres"
      - "-c"
      - "max_connections=200"
      - "-c"
      - "listen_addresses=*"
      - "-c"
      - "shared_buffers=256MB"
      - "-c"
      - "effective_cache_size=1GB"
      - "-c"
      - "work_mem=4MB"
    environment:
      POSTGRES_USER: user
      POSTGRES_PASSWORD: pass
      POSTGRES_DB: evolution_db
      POSTGRES_HOST_AUTH_METHOD: trust
    volumes:
      - postgres_evolution_data:/var/lib/postgresql/data
    networks:
      - evolution_net
    # Se você NÃO precisa acessar o Postgres de fora do servidor, deixa sem ports.
    # Se precisar, descomenta abaixo:
    # ports:
    #   - "5436:5432"

  redis-evolution:
    image: redis:7-alpine
    container_name: redis_evolution
    restart: unless-stopped
    command: >
      redis-server --port 6379 --appendonly yes
    volumes:
      - redis_evolution_data:/data
    networks:
      - evolution_net
    # Se você NÃO precisa acessar o Redis de fora do servidor, deixa sem ports.
    # Se precisar, descomenta abaixo:
    # ports:
    #   - "6380:6379"

volumes:
  evolution_instances:
  postgres_evolution_data:
  redis_evolution_data:
  portainer_data:

networks:
  evolution_net:
    driver: bridge