tva
← Insights

Docker multi-tenant senza dipendenze condivise accidentali

Un approfondimento aggiornato e orientato alla produzione che traduce la documentazione dei fornitori in controlli operativi, decisioni di migrazione e criteri di rilascio verificabili.

Cosa è cambiato nel 2026

Torniamo su questo tema perché i confini operativi sono cambiati. I principi di fondo restano validi, ma le versioni attuali rendono alcune scorciatoie del passato incomplete o rischiose. Questo approfondimento parte dalla documentazione ufficiale disponibile al 14 luglio 2026, distingue i fatti dalle scelte locali e tratta ogni modifica di configurazione come un intervento controllato in produzione.

Fonti primarie aggiornate

Come utilizzare questo aggiornamento

Partiamo dalle fonti primarie, registriamo le versioni realmente distribuite e definiamo il risultato osservabile prima di modificare qualsiasi impostazione. L’intervento reversibile più piccolo viene provato in un ambiente rappresentativo. Un comando eseguito con successo non è un criterio di accettazione: lo sono lo stato del servizio, l’integrità dei dati, la latenza, i confini di sicurezza e il tempo di ripristino. La sequenza diagnostica ancora utile dell’articolo precedente viene mantenuta come base operativa; gli esempi legati a una versione devono comunque essere verificati nella documentazione corrente.

Base operativa

Come creare un ambiente di sviluppo multi-tenant basato su template con 16 servizi containerizzati che funziona offline ma resta accessibile online attraverso routing basato su sottodomini

Gestire ambienti di sviluppo per piu clienti spesso significa scegliere tra configurazioni manuali complesse o soluzioni cloud costose. I deployment manuali sono dispendiosi in termini di tempo e soggetti a errori. Le piattaforme cloud sono comode ma creano vendor lock-in e costi ricorrenti che scalano con l'utilizzo.

Today, we’ll walk through building a scalable multi-tenant development stack that gives you both: complete isolation between client environments with automated deployment capabilities, all while maintaining full control over your infrastructure. This approach builds on our philosophy of self-hosted solutions—similar to how we’ve shown you can fare il self-hosting di n8n per l'automazione dei workflow and fare il deploy di Windmill con Docker per un controllo operativo completo.

Gli strumenti che utilizziamo

Iniziamo capendo cosa fa ciascun componente nella nostra architettura completa a 16 container:

Docker: la vostra base di containerizzazione

Docker fornisce l'isolamento e la coerenza di cui abbiamo bisogno per ambienti multi-tenant. Ogni cliente ottiene i propri container con configurazioni identiche, garantendo che cio che funziona in sviluppo funzionera anche in produzione. Pensatelo come avere piu server completamente separati in esecuzione sullo stesso hardware.

Il vantaggio chiave? Isolamento perfetto tra i clienti. I dati, le configurazioni e le personalizzazioni di un cliente non interferiscono mai con quelli di un altro. Questo e importante quando si gestiscono piu clienti aziendali con requisiti e esigenze di sicurezza diversi.

Traefik: reverse proxy intelligente e load balancer

Traefik agisce come un direttore del traffico intelligente, instradando automaticamente le richieste all'ambiente client corretto in base ai nomi di dominio. Invece di configurare manualmente regole Apache o Nginx complesse, Traefik legge le label dai vostri container Docker e configura il routing automaticamente.

Think of Traefik as a smart receptionist who knows exactly which office (container) each visitor (request) should go to, without you having to give directions every time. In our setup, Traefik handles SSL termination, automatic service discovery, and provides detailed monitoring dashboards.

Cloudflare Tunnels: accesso esterno sicuro

I Cloudflare Tunnels forniscono accesso sicuro al vostro stack di sviluppo locale senza configurazioni firewall complesse o VPN. Ogni dominio client ottiene il proprio tunnel, garantendo una separazione completa a livello di rete mantenendo sicurezza di livello enterprise.

The beauty is that your development environments remain local and secure, but clients can access their specific services from anywhere with proper authentication—similar to how we configured secure external access in our guida all'hosting di n8n.

Lo stack di servizi completo: tutto cio di cui i vostri clienti hanno bisogno

Il nostro stack multi-tenant include sette categorie di servizi principali su 16 container per cliente:

Automazione dei workflow e logica aziendale:

  • n8n: Complete workflow automation platform for business process automation
  • Authentik: Enterprise-grade single sign-on and identity management (3 containers: server, worker, Redis cache)

Database e servizi backend:

  • PostgreSQL: Robust database backend supporting all services with optimized connection pooling
  • Supabase Stack: Complete backend-as-a-service with 5 specialized containers (Studio, Auth, REST API, Realtime, Kong Gateway)
  • NocoDB: No-code database interface for client data management

AI e intelligenza:

  • Ollama: Local AI language models with GPU acceleration for intelligent automation
  • Qdrant (optional): Vector database for advanced AI workflows and similarity search

Infrastruttura e monitoraggio:

  • Cloudflare Tunnel: Secure external connectivity
  • Traefik: Reverse proxy with automatic SSL and monitoring dashboard

Come funziona il tutto insieme

Ecco il flusso completo quando un cliente accede al proprio ambiente:

  • Il cliente naviga verso il proprio dominio personalizzato (e.g., workflows.client-a.com)
  • Il Cloudflare Tunnel instrada la richiesta alla vostra istanza Traefik locale
  • Traefik legge il dominio, applica i middleware (autenticazione, SSL, rate limiting) e inoltra al container client corretto
  • Authentik gestisce l'autenticazione SSO su tutti i servizi se configurato
  • Il cliente ottiene il proprio ambiente completamente isolato con i propri dati e configurazioni
  • Tutti gli altri clienti rimangono completamente non interessati e inaccessibili

Tutto resta organizzato e separato, con ogni cliente che ottiene la propria struttura di sottodomini come auth.client-a.com, database.client-a.com, backend.client-a.com, etc.

Configurazione pratica: i passaggi concreti

Preparare le basi

First, you’ll need Docker Desktop installed and a domain management setup. We recommend setting up a wildcard DNS structure for easy client onboarding:

Creazione del sistema di template

La magia avviene attraverso un approccio basato su template. Invece di configurare manualmente ogni cliente, creiamo template che possono essere istantaneamente implementati con configurazioni specifiche per il cliente.

Crea la struttura completa delle directory:

Configurazione completa del template multi-servizio

Create a comprehensive docker-compose.yml template with all 16 services:

Template completo dell'ambiente

Create .env.template for comprehensive client-specific variables:

Script di inizializzazione del database

Create comprehensive database initialization in init/01-create-multiple-databases.sql:

Configurazione del Kong Gateway di Supabase

Create supabase/kong.yml for API gateway routing:

Script di deployment automatizzato

The comprehensive deployment script that creates new client environments in minutes:

Using Your Multi-Tenant Stack

Deploying New Clients

Creating a new client environment becomes trivial with our comprehensive script:

Each deployment creates:

  • Completely isolated Docker network with 16 containers
  • Separate data volumes for persistent storage
  • Unique service containers with health monitoring
  • Individual Cloudflare tunnel configuration
  • Custom domain routing with SSL certificates
  • Enterprise-grade SSO infrastructure ready for activation

Managing Multiple Environments

Monitor all client environments from a central location:

Container Architecture Deep Dive

Our complete 16-container architecture per client includes:

Infrastructure Layer (4 containers):

  • cloudflare-tunnel: Secure external connectivity
  • traefik: Reverse proxy with automatic SSL and service discovery
  • postgres: Central database with connection pooling
  • whoami: Health monitoring and routing verification

Application Layer (7 containers):

  • n8n: Workflow automation with PostgreSQL backend
  • nocodb: No-code database interface
  • supabase-studio: Backend development dashboard
  • supabase-meta: Database introspection service
  • supabase-auth: Authentication and user management
  • supabase-rest: Auto-generated REST API
  • supabase-realtime: Real-time subscriptions and updates

AI & Gateway Layer (2 containers):

  • ollama: Local AI with GPU acceleration support
  • supabase-kong: API gateway with rate limiting and CORS

Enterprise Security Layer (3 containers):

  • authentik-server: SSO authentication server
  • authentik-worker: Background tasks and notifications
  • authentik-redis: Session management and caching

Scaling Resources Per Client

Adjust resources based on client needs and usage patterns:

Real Benefits for Your Business

Complete Client Isolation with Enterprise Features

Each client gets their own comprehensive universe including enterprise-grade SSO, AI capabilities, and full backend infrastructure. Data, configurations, customizations, and security policies remain completely contained. A problem with one client never affects others, similar to the isolation we achieve with our individual n8n deployments.

Rapid Client Onboarding with Full Feature Set

New clients can be up and running with a complete development and automation stack in under 10 minutes. The deployment script handles all complex configuration, DNS setup, service initialization, and security configuration automatically—far more comprehensive than traditional approaches.

Predictable Enterprise Costs

After initial setup, there are no per-client hosting costs beyond your base infrastructure. Unlike SaaS solutions that charge per seat, per workflow, or per API call, you pay once for the hardware and run unlimited client environments with full enterprise features.

Professional Brand Consistency

Each client gets their own branded domains with professional subdomains (workflows.client.com, auth.client.com, etc.) and can customize their environments completely. No “powered by” footers or shared interfaces that dilute their brand identity.

The n8n Integration: Enterprise Workflow Automation at Scale

Here’s where things get really powerful. Just as we’ve shown you how to fare il self-hosting di n8n per l'automazione dei workflow, this multi-tenant setup gives each client their own complete n8n instance integrated with a full enterprise stack.

Each client can build sophisticated workflows that:

  • Connect to their own databases (NocoDB, Supabase PostgreSQL)
  • Use their own AI models (Ollama) for intelligent automation
  • Authenticate through enterprise SSO (Authentik)
  • Integrate with their specific business tools and APIs
  • Process their data with complete isolation and security

The combination creates a powerful client delivery platform where you can:

  • Deploy standardized automation capabilities rapidly
  • Customize workflows per client without affecting others
  • Scale your service delivery without linear cost increases
  • Maintain complete data sovereignty for each client
  • Offer enterprise-grade security and compliance

This approach builds on the same principles we used in our Windmill Docker setup guide, but extends it to a complete multi-tenant architecture.

Advanced Configuration Options

Implementing Enterprise SSO with Authentik

Enable single sign-on across all client services by configuring Authentik forward authentication:

Then update your service labels to use the middleware:

Adding Vector Database for Advanced AI

Enhance AI capabilities with Qdrant vector database:

Implementing Hybrid AI Architecture

For optimal performance, consider a hybrid approach combining containerized and native AI:

This provides 5-6x performance improvement through direct GPU access while maintaining container isolation for other services.

Monitoring and Observability Stack

Add comprehensive monitoring per client:

Common Issues and Solutions

“Service Unavailable” or HTTP 502 Errors

Usually means Traefik can’t reach the target container. Check that:

DNS Resolution Problems

Wildcard DNS setup is crucial for subdomain routing:

Resource Exhaustion Across Multiple Clients

Monitor resource usage across all client environments:

Database Connection Pool Exhaustion

PostgreSQL connection limits can be hit with many clients. Configure per deployment:

Authentik SSO Configuration Issues

Common SSO setup problems and solutions:

Cloudflare Tunnel Connection Issues

Debug tunnel connectivity problems:

Infrastructure Considerations

Sizing Your Infrastructure for Multiple Clients

For a typical setup handling 10-15 clients simultaneously with full 16-container stacks:

Minimum Requirements:

  • CPU: 16-24 cores (2 cores per active client environment)
  • RAM: 64-128GB (4-8GB per client depending on AI usage)
  • Storage: NVMe SSD with 2TB+ (databases, AI models, and logs grow over time)
  • Network: Gigabit connection for responsive client access

Recommended for Production:

  • Server: Hetzner CCX62 or similar (48 vCPU, 192GB RAM)
  • Storage: 4TB NVMe with automated backup system
  • Network: Multiple redundant connections
  • Monitoring: Full observability stack with alerting

Backup Strategy for Multi-Client Environments

Implement automated backups per client:

Security Hardening for Production

Implement comprehensive security best practices:

Apply security middleware to all client services:

Cost Analysis: The Numbers That Matter

Traditional SaaS Costs (10 enterprise clients with full feature sets)

Per-client monthly costs:

  • n8n Pro: $50/month per client = $500/month
  • Supabase Pro: $25/month per client = $250/month
  • NoCode platform (Airtable): $20/month per client = $200/month
  • Enterprise SSO (Auth0): $23/month per client = $230/month
  • AI API costs (OpenAI): $50/month per client = $500/month
  • Total: $1,500/month = $18,000/year

Self-Hosted Multi-Tenant Enterprise Stack Costs

Annual infrastructure costs:

  • Dedicated server (Hetzner CCX62): $350/month = $4,200/year
  • Domain costs (10 clients): $120/year
  • Cloudflare Pro (optional): $240/year
  • Total: $4,560/year

Annual savings: $13,440 (75% cost reduction)

Plus you get:

  • Complete data sovereignty and privacy
  • Unlimited customization and white-labeling
  • No vendor lock-in or API rate limits
  • Enterprise-grade security and compliance
  • Ability to offer reseller services
  • Full control over updates and features

This is particularly powerful when you consider that our setup provides enterprise features that would typically cost much more in SaaS subscriptions, similar to the cost benefits we demonstrated in our n8n self-hosting analysis.

Dalla configurazione alla decisione operativa

La domanda pratica non è se una piattaforma possa essere configurata. Il team deve saper attribuire le responsabilità, rilevare le derive, ripristinare il servizio senza improvvisare e dimostrare l’effetto previsto. Per questo associamo ogni modifica a un responsabile, una baseline, un percorso di rollback e una finestra di verifica. Una correzione isolata diventa così una capacità operativa affidabile. La stessa documentazione offre al responsabile successivo un punto di partenza affidabile e rende le ottimizzazioni future decisioni misurate anziché un nuovo ciclo di ipotesi.

Insights correlati

Articoli correlati