diff --git a/Dockerfile b/Dockerfile index c8f82d7..8ab2670 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,6 +22,10 @@ COPY . . # Disable Next.js telemetry during build ENV NEXT_TELEMETRY_DISABLED=1 +# Build-time argument for self-hosted draw.io URL +ARG NEXT_PUBLIC_DRAWIO_BASE_URL=https://embed.diagrams.net +ENV NEXT_PUBLIC_DRAWIO_BASE_URL=${NEXT_PUBLIC_DRAWIO_BASE_URL} + # Build Next.js application (standalone mode) RUN npm run build diff --git a/README.md b/README.md index 15fb23c..93a2071 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,8 @@ Open [http://localhost:3000](http://localhost:3000) in your browser. Replace the environment variables with your preferred AI provider configuration. See [Multi-Provider Support](#multi-provider-support) for available options. +> **Corporate Networks:** If `embed.diagrams.net` is blocked, see [Self-Hosted Draw.io](./docs/self-hosted-drawio.md) for configuration options. + ### Installation 1. Clone the repository: diff --git a/app/page.tsx b/app/page.tsx index 09c4007..210fbc2 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -11,6 +11,9 @@ import { } from "@/components/ui/resizable" import { useDiagram } from "@/contexts/diagram-context" +const drawioBaseUrl = + process.env.NEXT_PUBLIC_DRAWIO_BASE_URL || "https://embed.diagrams.net" + export default function Home() { const { drawioRef, handleDiagramExport, onDrawioLoad } = useDiagram() const [isMobile, setIsMobile] = useState(false) @@ -109,6 +112,7 @@ export default function Home() { ref={drawioRef} onExport={handleDiagramExport} onLoad={onDrawioLoad} + baseUrl={drawioBaseUrl} urlParameters={{ ui: drawioUi, spin: true, diff --git a/docs/self-hosted-drawio.md b/docs/self-hosted-drawio.md new file mode 100644 index 0000000..9243edb --- /dev/null +++ b/docs/self-hosted-drawio.md @@ -0,0 +1,57 @@ +# Self-Hosted Draw.io Configuration + +In some corporate environments, `embed.diagrams.net` is blocked by network policies. This guide explains how to use a self-hosted draw.io instance with Next AI Draw.io. + +## Configuration + +Set the `NEXT_PUBLIC_DRAWIO_BASE_URL` environment variable to point to your self-hosted draw.io instance. This is a **build-time** configuration, meaning you need to rebuild the Docker image to change the URL. + +## Docker Build + +```bash +# Build with custom draw.io URL +docker build --build-arg NEXT_PUBLIC_DRAWIO_BASE_URL=http://your-drawio-server:8080 -t next-ai-draw-io . + +# Run the custom build +docker run -d -p 3000:3000 --env-file .env next-ai-draw-io +``` + +## Docker Compose + +```yaml +services: + drawio: + image: jgraph/drawio:latest + ports: + - "8080:8080" + + next-ai-draw-io: + build: + context: . + args: + - NEXT_PUBLIC_DRAWIO_BASE_URL=http://drawio:8080 + ports: + - "3000:3000" + env_file: + - .env +``` + +## Running Draw.io Locally + +You can run the official draw.io Docker image: + +```bash +docker run -d -p 8080:8080 jgraph/drawio:latest +``` + +Then build Next AI Draw.io with: + +```bash +docker build --build-arg NEXT_PUBLIC_DRAWIO_BASE_URL=http://localhost:8080 -t next-ai-draw-io . +``` + +## Notes + +- The default draw.io URL is `https://embed.diagrams.net` +- Changes to `NEXT_PUBLIC_DRAWIO_BASE_URL` require rebuilding the Docker image +- For local development, you can set this in `.env.local` diff --git a/env.example b/env.example index 48ab91c..2e9a213 100644 --- a/env.example +++ b/env.example @@ -60,3 +60,7 @@ AI_MODEL=global.anthropic.claude-sonnet-4-5-20250929-v1:0 # Access Control (Optional) # ACCESS_CODE_LIST=your-secret-code,another-code + +# Draw.io Configuration (Optional) +# NEXT_PUBLIC_DRAWIO_BASE_URL=https://embed.diagrams.net # Default: https://embed.diagrams.net +# Use this to point to a self-hosted draw.io instance