Skip to content

Deploying a MiroTalk App

Introduction

MiroTalk is an open-source WebRTC video conferencing solution built on Node.js with signaling and TURN/STUN support. Deploying MiroTalk with a Dockerfile on Klutch.sh delivers reproducible builds, managed secrets, and persistent storage for logs and recordings—all configured from klutch.sh/app. This guide covers installation, repository prep, a production-ready Dockerfile, deployment steps, Nixpacks overrides, sample API usage, and production tips.


Prerequisites

  • A Klutch.sh account (sign up)
  • A GitHub repository containing your MiroTalk code and Dockerfile (GitHub is the only supported git source)
  • TURN/STUN credentials if you run your own ICE servers; otherwise use public STUN for testing
  • Domain and TLS for secure signaling

For onboarding, see the Quick Start.


Architecture and ports

  • MiroTalk signaling runs over HTTP(S); set the internal container port to 3000 and choose HTTP traffic.
  • WebRTC media flows peer-to-peer, but TURN may relay traffic; ensure your TURN server is reachable.
  • Persistent storage is optional for logs/recordings; configure a volume if you store them.

Repository layout

mirotalk/
├── Dockerfile # Must be at repo root for auto-detection
├── package.json
├── pnpm-lock.yaml # or yarn.lock / package-lock.json
├── .env.example # Template only; no secrets
└── README.md

Keep secrets out of Git; store them in Klutch.sh environment variables.


Installation (local) and starter commands

Validate locally before pushing to GitHub:

Terminal window
pnpm install
pnpm build
pnpm start -- --port 3000

Optional helper start.sh:

#!/usr/bin/env bash
set -euo pipefail
exec pnpm start -- --port "${PORT:-3000}"

Make it executable with chmod +x start.sh.


Dockerfile for MiroTalk (production-ready)

Place this Dockerfile at the repo root; Klutch.sh auto-detects it (no Docker selection in the UI):

FROM node:18-alpine AS build
WORKDIR /app
COPY package.json pnpm-lock.yaml* yarn.lock* package-lock.json* ./
RUN corepack enable
RUN pnpm install --frozen-lockfile
COPY . .
RUN pnpm build
FROM node:18-alpine
WORKDIR /app
ENV NODE_ENV=production PORT=3000
COPY --from=build /app /app
RUN corepack enable && pnpm install --prod --frozen-lockfile
EXPOSE 3000
CMD ["pnpm", "start", "--", "--port", "3000"]

Notes:

  • Add build tools (apk add --no-cache python3 make g++) if native modules are needed.
  • If you store recordings/logs locally, ensure the relevant directories are writable and mounted as volumes.

Environment variables (Klutch.sh)

Set these in Klutch.sh before deploying:

  • NODE_ENV=production
  • PORT=3000
  • APP_URL=https://example-app.klutch.sh
  • STUN_SERVERS=stun:stun.l.google.com:19302 (comma-separated list)
  • TURN_URL, TURN_USERNAME, TURN_PASSWORD (if using TURN)
  • Any auth/room configuration required by your MiroTalk variant

If you deploy without the Dockerfile and need Nixpacks overrides:

  • NIXPACKS_BUILD_CMD=pnpm install --frozen-lockfile && pnpm build
  • NIXPACKS_START_CMD=pnpm start -- --port 3000
  • NIXPACKS_NODE_VERSION=18

Attach persistent volumes

In Klutch.sh storage settings, add mount paths and sizes (no names required) if you persist data:

  • /app/logs — application logs if stored on disk.
  • /app/recordings — optional recorded sessions.

Ensure these paths are writable inside the container.


Deploy MiroTalk on Klutch.sh (Dockerfile workflow)

  1. Push your repository—with the Dockerfile at the root—to GitHub.
  2. Open klutch.sh/app, create a project, and add an app.
  3. Select HTTP traffic and set the internal port to 3000.
  4. Add the environment variables above, including STUN/TURN credentials.
  5. Attach persistent volumes for /app/logs and /app/recordings if you store them, sizing for your retention needs.
  6. Deploy. Your signaling server will be reachable at https://example-app.klutch.sh; configure your clients to point to this URL.

Sample API usage

Health check (adjust path for your variant):

Terminal window
curl -X GET "https://example-app.klutch.sh/health"

Join a room via WebSocket from the client side:

const socket = io("https://example-app.klutch.sh", {
transports: ["websocket"],
});
socket.emit("join", { room: "demo-room" });

Health checks and production tips

  • Add an HTTP probe to /health or a lightweight status route.
  • Enforce HTTPS at the edge; forward internally to port 3000.
  • Use your own TURN for reliable connectivity; keep credentials in Klutch.sh secrets and rotate them regularly.
  • Monitor resource usage; scale out if signaling load grows.
  • Pin Node and dependency versions; test upgrades in staging before production.

MiroTalk on Klutch.sh combines reproducible Docker builds with managed secrets, persistent storage, and flexible HTTP/TCP routing. With the Dockerfile at the repo root, port 3000 configured, and STUN/TURN set, you can deliver secure WebRTC meetings without extra YAML or workflow overhead.