Deploying draw.io
Introduction
draw.io (also known as diagrams.net) is a powerful, open-source diagramming application that enables users to create professional diagrams directly in their web browser. Originally created by JGraph Ltd, draw.io has become one of the most popular diagramming tools available, offering a feature-rich alternative to commercial solutions like Microsoft Visio or Lucidchart.
The self-hosted version of draw.io provides all the functionality of the cloud-hosted service while giving you complete control over your data. Built as a static web application that can run entirely in the browser, draw.io requires no server-side processing for diagram creation, making it lightweight and easy to deploy.
Key highlights of draw.io:
- Comprehensive Diagram Types: Create flowcharts, network diagrams, UML diagrams, org charts, mind maps, floor plans, and more
- Extensive Shape Libraries: Access thousands of pre-built shapes including AWS, Azure, GCP, Cisco, and many other vendor-specific icons
- Multiple Export Formats: Export diagrams as PNG, JPEG, SVG, PDF, VSDX, HTML, and XML
- Real-Time Collaboration: Work together on diagrams with team members simultaneously
- Cloud Storage Integration: Connect to Google Drive, OneDrive, Dropbox, GitHub, and GitLab for diagram storage
- Offline Support: Continue working on diagrams even without an internet connection
- Customizable: Extend with custom shape libraries and templates
- Privacy-Focused: Your diagrams remain private when self-hosted
- 100% Open Source: Licensed under Apache 2.0 with no premium features locked behind paywalls
This guide walks through deploying draw.io on Klutch.sh using Docker, configuring the application for your organization’s needs, and setting up storage integrations.
Why Deploy draw.io on Klutch.sh
Deploying draw.io on Klutch.sh provides several advantages for your diagramming needs:
Simplified Deployment: Klutch.sh automatically detects your Dockerfile and builds draw.io without complex orchestration. Push to GitHub, and your diagramming application deploys automatically.
Data Privacy: Keep all your diagrams and intellectual property within your own infrastructure. No diagram data is sent to third-party servers.
HTTPS by Default: Klutch.sh provides automatic SSL certificates, ensuring secure access to your diagramming tool from anywhere without manual certificate management.
GitHub Integration: Connect your configuration repository directly from GitHub. Updates to your Dockerfile trigger automatic redeployments, keeping your deployment in sync.
Custom Domains: Assign a custom domain to your draw.io instance for a professional, branded experience when sharing with your team.
Always-On Availability: Your diagramming tool remains accessible 24/7 without managing your own hardware or dealing with network configuration.
Resource Efficiency: draw.io is a lightweight static application, making it cost-effective to host on Klutch.sh.
Environment Variable Management: Configure storage integrations and customizations securely through Klutch.sh’s environment variable system.
Prerequisites
Before deploying draw.io on Klutch.sh, ensure you have:
- A Klutch.sh account
- A GitHub account with a repository for your draw.io configuration
- Basic familiarity with Docker and containerization concepts
- (Optional) OAuth credentials for Google Drive, OneDrive, or other storage integrations
- (Optional) A custom domain for your draw.io instance
Understanding draw.io Architecture
draw.io is primarily a client-side application with optional server components:
Static Web Application: The core diagramming functionality runs entirely in the browser using JavaScript. The server simply delivers the static files, requiring minimal server resources.
Storage Backends: draw.io can connect to various storage services for saving and loading diagrams. This includes local browser storage, cloud services, and self-hosted options.
Export Server (Optional): For advanced export features like PDF generation with custom fonts, an optional server-side component can be deployed.
Real-Time Collaboration: When enabled, collaboration features use WebSocket connections for real-time updates between users.
Preparing Your Repository
To deploy draw.io on Klutch.sh, create a GitHub repository containing your Dockerfile and any custom configuration.
Repository Structure
drawio-deploy/├── Dockerfile├── README.md└── .dockerignoreCreating the Dockerfile
Create a Dockerfile in the root of your repository. This example uses the official draw.io Docker image:
FROM jgraph/drawio:latest
# Optional: Set environment variables for configurationENV DRAWIO_SELF_CONTAINED=1ENV DRAWIO_BASE_URL=${DRAWIO_BASE_URL}
# The base image exposes port 8080 by defaultEXPOSE 8080
# The base image includes the default entrypointAdvanced Dockerfile with Custom Configuration
For more control over your deployment, use this extended Dockerfile:
FROM jgraph/drawio:latest
# Enable self-contained mode for offline functionalityENV DRAWIO_SELF_CONTAINED=1
# Set the base URL for your deploymentENV DRAWIO_BASE_URL=${DRAWIO_BASE_URL}
# Optional: Configure Google Drive integrationENV DRAWIO_GOOGLE_CLIENT_ID=${DRAWIO_GOOGLE_CLIENT_ID}ENV DRAWIO_GOOGLE_APP_ID=${DRAWIO_GOOGLE_APP_ID}
# Optional: Configure OneDrive integrationENV DRAWIO_MSGRAPH_CLIENT_ID=${DRAWIO_MSGRAPH_CLIENT_ID}
# Optional: Configure GitHub integrationENV DRAWIO_GITHUB_CLIENT_ID=${DRAWIO_GITHUB_CLIENT_ID}
# Optional: Configure GitLab integrationENV DRAWIO_GITLAB_ID=${DRAWIO_GITLAB_ID}ENV DRAWIO_GITLAB_URL=${DRAWIO_GITLAB_URL}
# Health checkHEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \ CMD wget --no-verbose --tries=1 --spider http://localhost:8080/ || exit 1
# Expose the application portEXPOSE 8080Creating the .dockerignore File
Create a .dockerignore file to exclude unnecessary files from the build:
.git.github*.mdREADME.mdLICENSE.gitignore*.log.DS_Store.env.env.localEnvironment Variables Reference
draw.io supports various environment variables for customization:
| Variable | Required | Default | Description |
|---|---|---|---|
DRAWIO_SELF_CONTAINED | No | 0 | Set to 1 to include all resources for offline use |
DRAWIO_BASE_URL | No | - | Base URL for your draw.io instance |
DRAWIO_CSP_HEADER | No | - | Custom Content Security Policy header |
DRAWIO_VIEWER_URL | No | - | URL to the draw.io viewer for embedded diagrams |
DRAWIO_GOOGLE_CLIENT_ID | No | - | Google OAuth client ID for Drive integration |
DRAWIO_GOOGLE_APP_ID | No | - | Google App ID for Drive integration |
DRAWIO_MSGRAPH_CLIENT_ID | No | - | Microsoft Graph client ID for OneDrive |
DRAWIO_GITHUB_CLIENT_ID | No | - | GitHub OAuth client ID |
DRAWIO_GITLAB_ID | No | - | GitLab OAuth application ID |
DRAWIO_GITLAB_URL | No | - | Self-hosted GitLab URL |
Deploying draw.io on Klutch.sh
Once your repository is prepared, follow these steps to deploy draw.io:
- Select HTTP as the traffic type
- Set the internal port to 8080 (draw.io’s default port)
- Detect your Dockerfile automatically
- Build the container image
- Start the draw.io container
- Provision an HTTPS certificate
Push Your Repository to GitHub
Initialize your repository and push to GitHub:
git initgit add Dockerfile .dockerignore README.mdgit commit -m "Initial draw.io deployment configuration"git remote add origin https://github.com/yourusername/drawio-deploy.gitgit push -u origin mainCreate a New Project on Klutch.sh
Navigate to the Klutch.sh dashboard and create a new project. Give it a descriptive name like “drawio” or “diagrams”.
Create a New App
Within your project, create a new app. Connect your GitHub account if you haven’t already, then select the repository containing your draw.io Dockerfile.
Configure HTTP Traffic
draw.io serves its web interface over HTTP. In the deployment settings:
Set Environment Variables
In the environment variables section, add any required configuration:
| Variable | Value |
|---|---|
DRAWIO_SELF_CONTAINED | 1 |
DRAWIO_BASE_URL | https://your-app-name.klutch.sh |
Add storage integration credentials if configuring cloud storage:
| Variable | Value |
|---|---|
DRAWIO_GOOGLE_CLIENT_ID | Your Google OAuth client ID |
DRAWIO_GOOGLE_APP_ID | Your Google App ID |
Deploy Your Application
Click Deploy to start the build process. Klutch.sh will:
Access draw.io
Once deployment completes, access your draw.io instance at https://your-app-name.klutch.sh. You can immediately start creating diagrams.
Initial Setup and Configuration
Getting Started with draw.io
When you first access your draw.io instance:
- Choose Storage Location: Select where to save your diagrams (Device, Browser, or connected cloud storage)
- Create New Diagram: Click “Create New Diagram” to start from scratch or select a template
- Open Existing: Open diagrams from your chosen storage location
Connecting Cloud Storage
Google Drive Integration
To enable Google Drive integration:
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the Google Drive API and Google Picker API
- Create OAuth 2.0 credentials (Web application type)
- Add your draw.io URL to authorized JavaScript origins
- Copy the Client ID and App ID to your environment variables
- Redeploy your application
OneDrive Integration
To enable OneDrive integration:
- Go to the Azure Portal
- Register a new application in Azure Active Directory
- Configure redirect URIs for your draw.io instance
- Grant Microsoft Graph permissions for Files.ReadWrite
- Copy the Application (client) ID to
DRAWIO_MSGRAPH_CLIENT_ID - Redeploy your application
GitHub Integration
To enable GitHub integration:
- Go to GitHub Settings > Developer settings > OAuth Apps
- Create a new OAuth application
- Set the authorization callback URL to your draw.io instance
- Copy the Client ID to
DRAWIO_GITHUB_CLIENT_ID - Redeploy your application
Customizing Templates
Create custom templates for your organization:
- Design your template diagram in draw.io
- Export as XML
- Host the template files on your server or configure them in the deployment
- Reference templates in your configuration
Working with Diagrams
Supported Diagram Types
draw.io supports a wide variety of diagram types:
| Category | Diagram Types |
|---|---|
| Business | Flowcharts, Org Charts, BPMN, Value Stream Maps |
| Software | UML, ERD, Sequence Diagrams, Class Diagrams |
| Network | Network Topology, Rack Diagrams, AWS/Azure/GCP Architecture |
| Engineering | Circuit Diagrams, Floor Plans, P&ID |
| General | Mind Maps, Venn Diagrams, Infographics |
Shape Libraries
Access specialized shape libraries:
- Click the ”+” button in the shapes panel
- Browse available libraries by category
- Enable libraries for AWS, Azure, GCP, Cisco, and more
- Search for specific shapes using the search bar
Export Options
Export your diagrams in multiple formats:
| Format | Use Case |
|---|---|
| PNG/JPEG | Web publishing, documentation |
| SVG | Scalable graphics, web embedding |
| Print-ready documents | |
| VSDX | Microsoft Visio compatibility |
| XML | Backup, version control |
| HTML | Interactive web embedding |
Real-Time Collaboration
Enabling Collaboration
draw.io supports real-time collaboration when connected to supported storage backends:
- Google Drive: Share the diagram file with collaborators
- OneDrive: Use standard OneDrive sharing
- Confluence: Built-in collaboration through Confluence
Collaboration Features
- Real-Time Updates: See changes from other users instantly
- Cursor Tracking: View where other users are working
- Comments: Add comments to specific diagram elements
- Version History: Access previous versions of your diagram
Security Configuration
Content Security Policy
Configure a custom CSP header for enhanced security:
ENV DRAWIO_CSP_HEADER="default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; connect-src 'self' https://api.github.com https://graph.microsoft.com https://www.googleapis.com"Access Control
For team deployments, consider implementing access control:
- Use Klutch.sh’s authentication features if available
- Deploy behind an authentication proxy like OAuth2 Proxy
- Restrict access at the network level
Production Best Practices
Performance Optimization
- CDN Integration: Use a CDN for static assets to improve load times
- Compression: Enable gzip compression in your reverse proxy
- Caching: Configure appropriate cache headers for static files
Backup Strategy
Protect your diagram data:
- Cloud Storage Backups: Diagrams stored in Google Drive, OneDrive, or GitHub are backed up by those services
- Export Regularly: Periodically export important diagrams as XML for local backup
- Version Control: Store diagram XML files in Git repositories for version history
Monitoring
Monitor your draw.io deployment:
- Klutch.sh Dashboard: View deployment health and logs
- Health Checks: The configured health check ensures container availability
- Usage Analytics: Consider adding privacy-respecting analytics if needed
Troubleshooting Common Issues
Application Won’t Load
Symptoms: Blank page or loading spinner that never completes.
Solutions:
- Clear browser cache and cookies
- Check browser console for JavaScript errors
- Verify the deployment is running in Klutch.sh dashboard
- Ensure port 8080 is correctly configured
Cloud Storage Connection Failed
Symptoms: Unable to connect to Google Drive, OneDrive, or other storage.
Solutions:
- Verify OAuth credentials are correctly configured
- Check that redirect URIs match your deployment URL
- Ensure required API permissions are granted
- Review browser console for authentication errors
Diagrams Not Saving
Symptoms: Changes are lost when closing the browser.
Solutions:
- Verify storage backend is properly configured
- Check browser storage permissions
- Use “Save As” to explicitly save to desired location
- Clear browser cache and try again
Export Features Not Working
Symptoms: PDF or other exports fail or produce incorrect output.
Solutions:
- Ensure the export server component is deployed if needed
- Check that all required fonts are available
- Try exporting to a different format
- Use the PNG export as a fallback
Performance Issues
Symptoms: Slow diagram loading or editing.
Solutions:
- Reduce diagram complexity
- Break large diagrams into smaller linked diagrams
- Clear browser cache
- Allocate additional resources if needed
Updating draw.io
To update to a newer version of draw.io:
- Review Release Notes: Check the draw.io releases for changes
- Update Dockerfile: If pinning to a specific version, update the tag
- Push Changes: Commit and push to trigger redeployment
- Verify: Test diagram creation and storage integrations
draw.io follows semantic versioning, and updates are generally backward compatible.
Additional Resources
- Official draw.io Website
- draw.io Documentation
- draw.io GitHub Repository
- draw.io Docker Repository
- draw.io Blog
- draw.io Support
- Klutch.sh Deployments
Conclusion
Deploying draw.io on Klutch.sh gives you a powerful, self-hosted diagramming solution with automatic builds, secure HTTPS access, and complete control over your data. The combination of draw.io’s feature-rich interface and Klutch.sh’s deployment simplicity means you can focus on creating professional diagrams rather than managing infrastructure.
With support for multiple diagram types, extensive shape libraries, and integration with popular cloud storage services, draw.io on Klutch.sh provides a comprehensive diagramming platform for individuals and teams. Whether you’re creating simple flowcharts or complex cloud architecture diagrams, draw.io delivers the tools you need with the privacy and control of self-hosting.