Merge pull request #5 from dograh-hq/feat/optimize-docker-image

Feat/optimize docker image
This commit is contained in:
Abhishek 2025-09-24 13:32:36 +05:30 committed by GitHub
commit 2dfe47c4df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 97 additions and 30 deletions

View file

@ -3,7 +3,7 @@
# Dograh AI
<h3 align="center"><strong>If you find value in this project, PLEASE STAR IT to help others discover our FOSS platform!</strong></h3>
<p align="center">
@ -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)
[![Watch a quick demo video](https://img.youtube.com/vi/LK8mvK5TH2Q/1.jpg)](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
<br><br><br>
<p align="center">
<a href="https://github.com/dograh-hq/dograh/stargazers">⭐ Star us on GitHub</a> |
<a href="https://www.dograh.com">☁️ Try Cloud Version</a> |
<a href="https://join.slack.com/t/dograh-community/shared_invite/zt-3czr47sw5-MSg1J0kJ7IMPOCHF~03auQ">💬 Join Slack</a>
</p>
<p align="center">
<a href="https://github.com/dograh-hq/dograh/stargazers">⭐ Star us on GitHub</a> |
<a href="https://app.dograh.com">☁️ Try Cloud Version</a> |
<a href="https://join.slack.com/t/dograh-community/shared_invite/zt-3czr47sw5-MSg1J0kJ7IMPOCHF~03auQ">💬 Join Slack</a>
</p>

View file

@ -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@9dbd5eb#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

View file

@ -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"]
# Start the production server using the standalone Node.js server
CMD ["node", "server.js"]

View file

@ -3,6 +3,7 @@ import type { NextConfig } from "next";
const nextConfig: NextConfig = {
/* config options here */
output: 'standalone',
experimental: {
serverSourceMaps: true,
},

View file

@ -231,7 +231,7 @@ export default function CreateWorkflowPage() {
You&apos;re encouraged to first test the bot and then modify it to your specific requirements and location (currency/accent etc).
</p>
<p className="pt-2 text-sm">
Feel free to join our <span className="font-semibold text-blue-600 dark:text-blue-400">Slack channel</span> for any queries and star us on <span className="font-semibold text-gray-900 dark:text-gray-100">GitHub</span>.
Feel free to join our Slack channel for any queries and star us on GitHub.
</p>
</div>
</DialogDescription>