services:
  n8n:
    image: docker.n8n.io/n8nio/n8n
    container_name: n8n
    environment:
      - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
      - N8N_RUNNERS_ENABLED=true
      - N8N_HOST=n8n.wibudev.com
      - N8N_PORT=5678
      - WEBHOOK_URL=https://n8n.wibudev.com/
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=wibu@bip.com
      - N8N_BASIC_AUTH_PASSWORD=Production_123
      - N8N_PROTOCOL=https
      - NODE_ENV=production
    volumes:
      - ./data/n8n:/home/node/.n8n
      - ./data/n8n/local-files:/files
    restart: always
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:5678"]
      interval: 30s
      timeout: 5s
      retries: 5
      start_period: 20s
    networks:
      - n8n-network

  n8n-frpc:
    image: snowdreamtech/frpc:latest
    container_name: n8n-frpc
    restart: always
    volumes:
      - ./data/frpc/frpc.toml:/etc/frp/frpc.toml:ro
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"
    depends_on:
      n8n:
        condition: service_healthy
    networks:
      - n8n-network

networks:
  n8n-network:
    driver: bridge
