From 548e6f885b159aaa626939942994359a22c663d6 Mon Sep 17 00:00:00 2001
From: Sabiha Khan
Date: Thu, 18 Sep 2025 19:51:47 +0530
Subject: [PATCH 1/6] feat: multi stage dockerfile
---
api/Dockerfile | 47 ++++++++++++++++++++++++++++++-----
ui/Dockerfile | 63 +++++++++++++++++++++++++++++++++++------------
ui/next.config.ts | 1 +
3 files changed, 89 insertions(+), 22 deletions(-)
diff --git a/api/Dockerfile b/api/Dockerfile
index 35d2a4e..022057f 100644
--- a/api/Dockerfile
+++ b/api/Dockerfile
@@ -1,23 +1,58 @@
-# Dockerfile
-FROM python:3.12-slim
+# Multi-stage Dockerfile
+# Stage 1: Builder - Install Python dependencies
+FROM python:3.12-slim AS builder
WORKDIR /app
+# Install git in builder stage (needed for pip install from git)
RUN apt-get update && apt-get install -y \
git \
- ffmpeg \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Copy and install requirements
COPY requirements.txt .
-RUN pip install --no-cache-dir -r requirements.txt
+# Install dependencies to user directory for easy copying
+RUN pip install --user --no-cache-dir -r requirements.txt && \
+ # Clean up pip cache after installation
+ rm -rf /root/.cache/pip
# Force reinstall of pipecat on every build (cache bust)
-ARG CACHEBUST=1
-RUN pip install 'git+https://github.com/dograh-hq/pipecat.git@main#egg=pipecat-ai[cartesia,deepgram,openai,elevenlabs,groq,google,azure]'
+ARG CACHEBUST=1
+RUN pip install --user 'git+https://github.com/dograh-hq/pipecat.git@main#egg=pipecat-ai[cartesia,deepgram,openai,elevenlabs,groq,google,azure]' && \
+ # Clean up pip cache after pipecat installation
+ rm -rf /root/.cache/pip
+
+# Remove unnecessary Python cache files from installed packages
+RUN find /root/.local -type f -name '*.pyc' -delete && \
+ find /root/.local -type d -name '__pycache__' -delete && \
+ find /root/.local -type f -name '*.pyo' -delete
+
+# Stage 2: Runtime - Minimal image with only runtime dependencies
+FROM python:3.12-slim AS runner
+
+WORKDIR /app
+
+# Only install ffmpeg (runtime dependency)
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ ffmpeg \
+ && apt-get clean \
+ && rm -rf /var/lib/apt/lists/*
+
+# Copy Python packages from builder stage
+COPY --from=builder /root/.local /root/.local
+
+# Make sure scripts in .local are available
+ENV PATH=/root/.local/bin:$PATH
+
+# Set Python to not generate .pyc files in runtime
+ENV PYTHONDONTWRITEBYTECODE=1
+# Unbuffered output for better container logging
+ENV PYTHONUNBUFFERED=1
+
+# Copy application code
COPY . ./api
ENV PYTHONPATH=/app
diff --git a/ui/Dockerfile b/ui/Dockerfile
index 3d0b757..095f6de 100644
--- a/ui/Dockerfile
+++ b/ui/Dockerfile
@@ -1,15 +1,22 @@
-FROM node:20-alpine
-
+# Multi-stage build
+# Stage 1: Dependencies
+FROM node:20-alpine AS deps
WORKDIR /app
-ENV NEXT_PUBLIC_NODE_ENV=local
-ENV NEXT_PUBLIC_AUTH_PROVIDER=local
-ENV NEXT_PUBLIC_DEPLOYMENT_MODE=oss
-ENV NEXT_PUBLIC_BACKEND_URL="http://localhost:8000"
-ENV BACKEND_URL="http://api:8000"
+# Copy package files
+COPY package*.json ./
+# Install all dependencies (including dev dependencies for building)
+RUN npm ci --cache /tmp/empty-cache && \
+ npm cache clean --force
+# Stage 2: Builder
+FROM node:20-alpine AS builder
+WORKDIR /app
-# Copy package files and other config files needed for build
+# Copy dependencies from deps stage
+COPY --from=deps /app/node_modules ./node_modules
+
+# Copy all files needed for build
COPY package*.json ./
COPY tsconfig.json ./
COPY next.config.ts ./
@@ -17,18 +24,42 @@ COPY components.json ./
COPY sentry.edge.config.ts ./
COPY sentry.server.config.ts ./
COPY postcss.config.mjs ./
-
-# Install dependencies (including dev deps for building)
-RUN npm ci
-
-# Copy all source file
COPY public ./public
COPY src ./src
-RUN npm run build
+# Set build-time environment variables (needed for Next.js build)
+ENV NEXT_PUBLIC_NODE_ENV=local
+ENV NEXT_PUBLIC_AUTH_PROVIDER=local
+ENV NEXT_PUBLIC_DEPLOYMENT_MODE=oss
+ENV NEXT_PUBLIC_BACKEND_URL="http://localhost:8000"
+ENV BACKEND_URL="http://api:8000"
+ENV NEXT_TELEMETRY_DISABLED=1
+
+# Build the application with standalone mode
+RUN npm run build && \
+ rm -rf /tmp/* /root/.npm /root/.next/cache
+
+# Stage 3: Runner (production image)
+FROM node:20-alpine AS runner
+WORKDIR /app
+
+# Environment variables will be provided by docker-compose
+ENV NODE_ENV=production
+
+# Create a non-root user
+RUN addgroup --system --gid 1001 nodejs && \
+ adduser --system --uid 1001 nextjs
+
+# Copy standalone build output
+COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
+COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
+COPY --from=builder --chown=nextjs:nodejs /app/public ./public
+
+# Switch to non-root user
+USER nextjs
# Expose the port Next.js runs on
EXPOSE 3000
-# Start the production server
-CMD ["npm", "run", "start"]
\ No newline at end of file
+# Start the production server using the standalone Node.js server
+CMD ["node", "server.js"]
\ No newline at end of file
diff --git a/ui/next.config.ts b/ui/next.config.ts
index 604a811..2ece625 100644
--- a/ui/next.config.ts
+++ b/ui/next.config.ts
@@ -3,6 +3,7 @@ import type { NextConfig } from "next";
const nextConfig: NextConfig = {
/* config options here */
+ output: 'standalone',
experimental: {
serverSourceMaps: true,
},
From d6acb91c39f1513549fed54cb08bb544ff650245 Mon Sep 17 00:00:00 2001
From: Sabiha Khan
Date: Thu, 18 Sep 2025 20:02:47 +0530
Subject: [PATCH 2/6] chore: update README, remove style in workflow
continuation dialog
---
README.md | 14 +++++++-------
api/Dockerfile | 2 +-
ui/src/app/create-workflow/page.tsx | 2 +-
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index 633e7ad..3e243ca 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
# Dograh AI
-
+⭐ If you find value in this project, PLEASE STAR IT to help others discover our FOSS platform!
@@ -23,7 +23,7 @@ Build voice agents in just one line or drag-and-drop, then test them using AI pe
Maintained by YC alumni and exit founders, we're making sure the future of voice AI stays open, not monopolized.
## 🎥 Demo Video
-📺 [Watch a quick demo video](https://www.youtube.com/watch?v=LK8mvK5TH2Q)
+[](https://www.youtube.com/watch?v=LK8mvK5TH2Q)
## 🚀 Get Started
@@ -212,9 +212,9 @@ Founded by YC alumni and exit founders committed to keeping voice AI open and ac
-
- ⭐ Star us on GitHub |
- ☁️ Try Cloud Version |
- 💬 Join Slack
-
+
+ ⭐ Star us on GitHub |
+ ☁️ Try Cloud Version |
+ 💬 Join Slack
+
diff --git a/api/Dockerfile b/api/Dockerfile
index 022057f..624ab0c 100644
--- a/api/Dockerfile
+++ b/api/Dockerfile
@@ -21,7 +21,7 @@ RUN pip install --user --no-cache-dir -r requirements.txt && \
# Force reinstall of pipecat on every build (cache bust)
ARG CACHEBUST=1
-RUN pip install --user 'git+https://github.com/dograh-hq/pipecat.git@main#egg=pipecat-ai[cartesia,deepgram,openai,elevenlabs,groq,google,azure]' && \
+RUN pip install --user 'git+https://github.com/dograh-hq/pipecat.git@9dbd5eb#egg=pipecat-ai[cartesia,deepgram,openai,elevenlabs,groq,google,azure]' && \
# Clean up pip cache after pipecat installation
rm -rf /root/.cache/pip
diff --git a/ui/src/app/create-workflow/page.tsx b/ui/src/app/create-workflow/page.tsx
index 91a4acb..570c441 100644
--- a/ui/src/app/create-workflow/page.tsx
+++ b/ui/src/app/create-workflow/page.tsx
@@ -231,7 +231,7 @@ export default function CreateWorkflowPage() {
You're encouraged to first test the bot and then modify it to your specific requirements and location (currency/accent etc).
- Feel free to join our Slack channel for any queries and star us on GitHub.
+ Feel free to join our Slack channel for any queries and star us on GitHub.
From 73664e6268842af1793a089698ec6306cab7683a Mon Sep 17 00:00:00 2001
From: Abhishek Kumar
Date: Mon, 22 Sep 2025 20:34:52 +0530
Subject: [PATCH 3/6] fix: redirect user to /workflow page if they have
workflow
---
ui/src/app/after-sign-in/page.tsx | 40 ++++++++++++++++++++++++++++---
ui/src/app/page.tsx | 40 +++++++++++++++++++++++++++----
ui/src/lib/utils.ts | 33 +++++++++++++++++++++++--
3 files changed, 104 insertions(+), 9 deletions(-)
diff --git a/ui/src/app/after-sign-in/page.tsx b/ui/src/app/after-sign-in/page.tsx
index eabad50..cbc16d6 100644
--- a/ui/src/app/after-sign-in/page.tsx
+++ b/ui/src/app/after-sign-in/page.tsx
@@ -1,6 +1,7 @@
import { redirect } from "next/navigation";
-import { getServerAuthProvider, getServerUser } from "@/lib/auth/server";
+import { getWorkflowsApiV1WorkflowFetchGet } from "@/client/sdk.gen";
+import { getServerAccessToken,getServerAuthProvider, getServerUser } from "@/lib/auth/server";
import logger from '@/lib/logger';
import { getRedirectUrl } from "@/lib/utils";
@@ -26,7 +27,40 @@ export default async function AfterSignInPage() {
logger.debug('[AfterSignInPage] Redirecting to:', redirectUrl);
redirect(redirectUrl);
}
- // For local provider or if user is not available, redirect to create-workflow
- logger.debug('[AfterSignInPage] Fallback redirect to /create-workflow');
+
+ // For local provider or if user is not available, check for existing workflows
+ logger.debug('[AfterSignInPage] Checking for existing workflows before fallback');
+
+ try {
+ const accessToken = await getServerAccessToken();
+ if (accessToken) {
+ const workflowsResponse = await getWorkflowsApiV1WorkflowFetchGet({
+ headers: {
+ Authorization: `Bearer ${accessToken}`,
+ },
+ });
+
+ const workflows = workflowsResponse.data ? (Array.isArray(workflowsResponse.data) ? workflowsResponse.data : [workflowsResponse.data]) : [];
+ const activeWorkflows = workflows.filter(w => w.status === 'active');
+
+ logger.debug('[AfterSignInPage] Found workflows:', {
+ total: workflows.length,
+ active: activeWorkflows.length
+ });
+
+ if (activeWorkflows.length > 0) {
+ logger.debug('[AfterSignInPage] Redirecting to /workflow - user has workflows');
+ redirect('/workflow');
+ } else {
+ logger.debug('[AfterSignInPage] Redirecting to /create-workflow - no workflows found');
+ redirect('/create-workflow');
+ }
+ }
+ } catch (error) {
+ logger.error('[AfterSignInPage] Error checking workflows:', error);
+ }
+
+ // Default fallback
+ logger.debug('[AfterSignInPage] Final fallback redirect to /create-workflow');
redirect('/create-workflow');
}
diff --git a/ui/src/app/page.tsx b/ui/src/app/page.tsx
index c7338f9..fff4bc6 100644
--- a/ui/src/app/page.tsx
+++ b/ui/src/app/page.tsx
@@ -1,7 +1,8 @@
import { redirect } from "next/navigation";
+import { getWorkflowsApiV1WorkflowFetchGet } from "@/client/sdk.gen";
import SignInClient from "@/components/SignInClient";
-import { getServerAuthProvider,getServerUser } from "@/lib/auth/server";
+import { getServerAccessToken,getServerAuthProvider,getServerUser } from "@/lib/auth/server";
import logger from '@/lib/logger';
import { getRedirectUrl } from "@/lib/utils";
@@ -12,10 +13,41 @@ export default async function Home() {
const authProvider = getServerAuthProvider();
logger.debug('[HomePage] Auth provider:', authProvider);
- // For local/OSS provider, always redirect to workflow page
+ // For local/OSS provider, check if user has workflows
if (authProvider === 'local') {
- logger.debug('[HomePage] Redirecting to workflow page for local provider');
- redirect('/create-workflow');
+ logger.debug('[HomePage] Local provider detected, checking for workflows');
+
+ try {
+ const accessToken = await getServerAccessToken();
+ if (accessToken) {
+ const workflowsResponse = await getWorkflowsApiV1WorkflowFetchGet({
+ headers: {
+ Authorization: `Bearer ${accessToken}`,
+ },
+ });
+
+ const workflows = workflowsResponse.data ? (Array.isArray(workflowsResponse.data) ? workflowsResponse.data : [workflowsResponse.data]) : [];
+ const activeWorkflows = workflows.filter(w => w.status === 'active');
+
+ logger.debug('[HomePage] Found workflows for local provider:', {
+ total: workflows.length,
+ active: activeWorkflows.length
+ });
+
+ if (activeWorkflows.length > 0) {
+ logger.debug('[HomePage] Redirecting to /workflow - user has workflows');
+ redirect('/workflow');
+ } else {
+ logger.debug('[HomePage] Redirecting to /create-workflow - no workflows found');
+ redirect('/create-workflow');
+ }
+ }
+ } catch (error) {
+ logger.error('[HomePage] Error checking workflows for local provider:', error);
+ // Default to create-workflow on error
+ logger.debug('[HomePage] Defaulting to /create-workflow due to error');
+ redirect('/create-workflow');
+ }
}
logger.debug('[HomePage] Getting server user...');
diff --git a/ui/src/lib/utils.ts b/ui/src/lib/utils.ts
index 0bb755e..5670141 100644
--- a/ui/src/lib/utils.ts
+++ b/ui/src/lib/utils.ts
@@ -2,6 +2,7 @@ import { type ClassValue, clsx } from "clsx"
import { twMerge } from "tailwind-merge"
import { getAuthUserApiV1UserAuthUserGet } from "@/client/sdk.gen";
+import { getWorkflowsApiV1WorkflowFetchGet } from "@/client/sdk.gen";
import { impersonateApiV1SuperuserImpersonatePost } from "@/client/sdk.gen";
export function cn(...inputs: ClassValue[]) {
@@ -60,8 +61,36 @@ export async function getRedirectUrl(token: string, permissions: { id: string }[
return "/usage";
}
- console.log('[getRedirectUrl] Has admin permission, redirecting to /create-workflow');
- return "/create-workflow";
+ // Check if user has any workflows
+ try {
+ console.log('[getRedirectUrl] Checking for existing workflows...');
+ const workflowsResponse = await getWorkflowsApiV1WorkflowFetchGet({
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ });
+
+ const workflows = workflowsResponse.data ? (Array.isArray(workflowsResponse.data) ? workflowsResponse.data : [workflowsResponse.data]) : [];
+ const activeWorkflows = workflows.filter(w => w.status === 'active');
+
+ console.log('[getRedirectUrl] Found workflows:', {
+ total: workflows.length,
+ active: activeWorkflows.length
+ });
+
+ if (activeWorkflows.length > 0) {
+ console.log('[getRedirectUrl] User has workflows, redirecting to /workflow');
+ return "/workflow";
+ } else {
+ console.log('[getRedirectUrl] No workflows found, redirecting to /create-workflow');
+ return "/create-workflow";
+ }
+ } catch (error) {
+ console.error('[getRedirectUrl] Error checking workflows:', error);
+ // If we can't check workflows, default to create-workflow
+ console.log('[getRedirectUrl] Defaulting to /create-workflow due to error');
+ return "/create-workflow";
+ }
} catch (error) {
console.error("[getRedirectUrl] Failed to fetch auth user:", error);
// Re-throw the error so the caller can handle it
From 490639309bb93ee9fce081adae753cb9ec8abc0b Mon Sep 17 00:00:00 2001
From: Sabiha Khan
Date: Wed, 24 Sep 2025 11:53:48 +0530
Subject: [PATCH 4/6] fix: rethrow NEXT_REDIRECT error
---
ui/src/app/page.tsx | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/ui/src/app/page.tsx b/ui/src/app/page.tsx
index fff4bc6..a235ec8 100644
--- a/ui/src/app/page.tsx
+++ b/ui/src/app/page.tsx
@@ -1,4 +1,5 @@
import { redirect } from "next/navigation";
+import { isNextRouterError } from "next/dist/client/components/is-next-router-error";
import { getWorkflowsApiV1WorkflowFetchGet } from "@/client/sdk.gen";
import SignInClient from "@/components/SignInClient";
@@ -43,8 +44,13 @@ export default async function Home() {
}
}
} catch (error) {
+ // Re-throw navigation errors (redirects, not found, etc.) - they're intentional
+ if (isNextRouterError(error)) {
+ throw error;
+ }
+
logger.error('[HomePage] Error checking workflows for local provider:', error);
- // Default to create-workflow on error
+ // Default to create-workflow on actual errors
logger.debug('[HomePage] Defaulting to /create-workflow due to error');
redirect('/create-workflow');
}
From 28926d026f3e1514e3f749dfc68df902edbbd5cf Mon Sep 17 00:00:00 2001
From: Sabiha Khan
Date: Wed, 24 Sep 2025 12:01:35 +0530
Subject: [PATCH 5/6] fix: link for 'Try Cloud Version' in README
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 3e243ca..68c39d4 100644
--- a/README.md
+++ b/README.md
@@ -214,7 +214,7 @@ Founded by YC alumni and exit founders committed to keeping voice AI open and ac
⭐ Star us on GitHub |
- ☁️ Try Cloud Version |
+ ☁️ Try Cloud Version |
💬 Join Slack
From 8376e3e949fc72b682d9b696a6ff640be79d51f9 Mon Sep 17 00:00:00 2001
From: Abhishek Kumar
Date: Wed, 24 Sep 2025 13:36:36 +0530
Subject: [PATCH 6/6] Feat: set start metadata in pipeline
This is needed so that we can send correlation id for workflow runs in Dograh MPS
---
api/Dockerfile | 2 +-
api/requirements.txt | 2 +-
api/services/pipecat/pipeline_builder.py | 1 +
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/api/Dockerfile b/api/Dockerfile
index 624ab0c..1e861cf 100644
--- a/api/Dockerfile
+++ b/api/Dockerfile
@@ -21,7 +21,7 @@ RUN pip install --user --no-cache-dir -r requirements.txt && \
# Force reinstall of pipecat on every build (cache bust)
ARG CACHEBUST=1
-RUN pip install --user 'git+https://github.com/dograh-hq/pipecat.git@9dbd5eb#egg=pipecat-ai[cartesia,deepgram,openai,elevenlabs,groq,google,azure]' && \
+RUN pip install --user 'git+https://github.com/dograh-hq/pipecat.git@bcbd158#egg=pipecat-ai[cartesia,deepgram,openai,elevenlabs,groq,google,azure]' && \
# Clean up pip cache after pipecat installation
rm -rf /root/.cache/pip
diff --git a/api/requirements.txt b/api/requirements.txt
index bc5821a..e8acbc0 100644
--- a/api/requirements.txt
+++ b/api/requirements.txt
@@ -1,4 +1,4 @@
-pipecat-ai[cartesia,deepgram,openai,elevenlabs,groq,google,azure,soundfile,silero,webrtc] @ git+https://github.com/dograh-hq/pipecat.git@c327208
+pipecat-ai[cartesia,deepgram,openai,elevenlabs,groq,google,azure,soundfile,silero,webrtc] @ git+https://github.com/dograh-hq/pipecat.git@bcbd158
langfuse==3.4.0
fastapi==0.116.2
asyncpg==0.30.0
diff --git a/api/services/pipecat/pipeline_builder.py b/api/services/pipecat/pipeline_builder.py
index cab5317..d4562f5 100644
--- a/api/services/pipecat/pipeline_builder.py
+++ b/api/services/pipecat/pipeline_builder.py
@@ -105,6 +105,7 @@ def create_pipeline_task(pipeline, workflow_run_id, audio_config: AudioConfig =
enable_usage_metrics=True,
send_initial_empty_metrics=False,
enable_heartbeats=True,
+ start_metadata={"workflow_run_id": workflow_run_id},
)
# If audio_config is provided, set the audio sample rates