{"slug": "self-host-emdash-cms-docker-guide-for-homelab-servers", "title": "Self-Host EmDash CMS: Docker Guide for Homelab Servers", "summary": "A developer published a Docker guide for self-hosting Cloudflare's open-source EmDash CMS off Cloudflare's edge, swapping the default Workers, D1 and R2 stack for Astro's Node adapter, PostgreSQL and local filesystem storage. The guide covers sandboxed plugin execution via the @emdash-cms/sandbox-workerd package, which spawns a workerd child process inside the container, and warns that Node's default heap limit can crash the Vite bundling phase unless NODE_OPTIONS is raised to 4096MB. It also cites deployment benchmarks showing roughly 38 percent higher throughput under load when moving the base image from Node 22 to Node 24.", "body_md": "Cloudflare released EmDash CMS as an open-source Astro CMS featuring native Model Context Protocol (MCP) support and sandboxed plugins. While the official documentation defaults to Cloudflare Workers, D1 databases, and R2 storage, you can self-host EmDash on any Linux server or Docker homelab stack using Node.js and PostgreSQL. Running the CMS in a container eliminates D1 write latency and keeps all content data local to your infrastructure.\n\nThis guide outlines the practical steps, configuration requirements, and common deployment traps when hosting the EmDash Astro CMS entirely off-edge.\n\nA self-hosted EmDash instance behaves differently than a Cloudflare Worker deployment. Instead of relying on serverless edge functions, the setup relies on Astro's standard Node adapter.\n\nWhen you run the build command, Astro compiles the CMS into a standalone Node server. This server handles routing, serves the API endpoints for the admin panel, and manages the Kysely database migrations.\n\nThe primary difference lies in the plugin architecture. Cloudflare designed EmDash to eliminate the security risks of traditional WordPress plugins by sandboxing third-party code. In a Node.js deployment, the CMS maintains this security boundary using the `@emdash-cms/sandbox-workerd` package. When a plugin executes, this package spawns a `workerd` child process inside your container. The base operating system in your Docker image must have sufficient permissions and memory limits to allow this child process to run without being terminated by the Linux Out-Of-Memory killer.\n\nBefore you can build a Docker image, you must configure the project repository generated by `npm create emdash` for a server environment. The default scaffolding targets Cloudflare.\n\nYou need to modify your `astro.config.mjs` file. Swap the default Cloudflare adapter for `@astrojs/node` and set the build output to `server`. You also need to update the database configuration block to accept a PostgreSQL connection string, which you will pass via an environment variable in your Docker Compose file. Media storage should be set to target the local filesystem adapter pointed at an upload directory, rather than R2.\n\nDeploying EmDash requires two containers: the Node.js application and a PostgreSQL database. While EmDash technically supports SQLite, using PostgreSQL in a Docker environment prevents the database lock issues that occur when concurrent writes hit a SQLite file mounted across a volume bind.\n\nSave the following configuration as `compose.yaml` on your homelab server.\n\n```\nservices:\n  emdash-db:\n    image: postgres:16-alpine\n    restart: unless-stopped\n    environment:\n      POSTGRES_USER: emdash\n      POSTGRES_PASSWORD: your_secure_password\n      POSTGRES_DB: emdash_prod\n    volumes:\n      - emdash_db_data:/var/lib/postgresql/data\n    networks:\n      - emdash_net\n\n  emdash-app:\n    build: .\n    restart: unless-stopped\n    depends_on:\n      - emdash-db\n    environment:\n      - HOST=0.0.0.0\n      - PORT=4321\n      - DATABASE_URL=postgres://emdash:your_secure_password@emdash-db:5432/emdash_prod\n      - EMDASH_SITE_URL=https://cms.yourdomain.com\n      - EMDASH_ENCRYPTION_KEY=your_generated_encryption_key\n    volumes:\n      - emdash_uploads:/app/uploads\n    networks:\n      - emdash_net\n      - proxy_net\n\nvolumes:\n  emdash_db_data:\n  emdash_uploads:\n\nnetworks:\n  emdash_net:\n    internal: true\n  proxy_net:\n    external: true\n```\n\nThe application container relies on a custom `Dockerfile` placed in the same directory. The build process requires significant memory. Node's default heap limit is often exceeded during the Vite bundling phase of the Astro build. Setting `NODE_OPTIONS=--max-old-space-size=4096` prevents the build from crashing.\n\nRecent deployment benchmarks indicate that upgrading the base image from Node 22 to Node 24 yields an approximate 38 percent increase in throughput under load.\n\n```\nFROM node:24-slim AS build\nWORKDIR /app\nCOPY package.json pnpm-lock.yaml ./\nRUN corepack enable && pnpm install --frozen-lockfile\nCOPY . .\nENV NODE_OPTIONS=--max-old-space-size=4096\nRUN pnpm run build\n\nFROM node:24-slim\nWORKDIR /app\nCOPY --from=build /app/dist ./dist\nCOPY --from=build /app/node_modules ./node_modules\nCOPY --from=build /app/package.json ./\nRUN mkdir -p /app/uploads\nENV HOST=0.0.0.0\nENV PORT=4321\nEXPOSE 4321\nCMD [\"node\", \"./dist/server/entry.mjs\"]\n```\n\nThe `proxy_net` network in the Docker Compose file allows a reverse proxy to route traffic to the application. If you use Caddy, the configuration block is minimal.\n\n```\ncms.yourdomain.com {\n    reverse_proxy emdash-app:4321\n}\n```\n\nThe reverse proxy must terminate TLS and provide a valid HTTPS certificate. EmDash is strict regarding secure contexts due to its authentication model, which breaks entirely over plain HTTP or mismatched domains.\n\nThe most common failure point when moving EmDash to a self-hosted environment is authentication. EmDash uses WebAuthn (Passkeys) natively. There is no traditional username and password fallback provided out of the box.\n\nWebAuthn is tied strictly to the browser's origin. The browser will outright reject a passkey registration or login request if the site lacks HTTPS, unless accessed via `localhost`. Furthermore, EmDash reads the `EMDASH_SITE_URL` environment variable at runtime to determine the expected WebAuthn origin.\n\nIf you access the CMS via an internal IP address (for example, `192.168.1.50`) but `EMDASH_SITE_URL` is set to a public domain, the origin check fails and you remain locked out. Your reverse proxy domain, the certificate, and the `EMDASH_SITE_URL` value must match exactly.\n\nEmDash requires a storage backend for user uploads, images, and media assets. In a Cloudflare deployment, this defaults to R2 object storage. In a Docker setup, you have two options.\n\nThe simplest approach is local disk storage. The CMS will write files directly to the container's filesystem. The Docker Compose file maps a persistent volume to `/app/uploads` to ensure images survive container recreations.\n\nAlternatively, EmDash supports S3-compatible storage endpoints natively. If your homelab already runs MinIO, or if you prefer an external provider like Bunny S3 to serve media via a pull zone, you can define the S3 credentials in your environment variables. This keeps the application container entirely stateless, removing the need for the `emdash_uploads` volume and simplifying server migrations.\n\nEmDash ships with a native Model Context Protocol (MCP) server. This exposes your content, schema, media, and taxonomies to external AI tools like Claude or specialized agent software.\n\nIn a self-hosted Docker environment, this MCP server runs alongside your Node process. AI agents querying your CMS can generate sudden spikes in database reads and writes. This is the primary reason PostgreSQL is strictly recommended over SQLite for Docker deployments. While a single human editor might rarely encounter a SQLite database lock, an automated agent iterating through taxonomies and drafting revisions will quickly trigger concurrent write errors if the database backend cannot handle parallel operations.\n\nRunning the plugin sandbox locally requires accounting for memory overhead. Because `@emdash-cms/sandbox-workerd` initiates a separate `workerd` process for plugin execution, an EmDash container configured with tight memory constraints will experience silent failures.\n\nIf you cap your Docker containers using resource limits, assigning 512MB to the EmDash app container is insufficient. The Linux Out-Of-Memory killer will terminate the `workerd` child process when a memory-intensive plugin executes. A safe baseline for a production EmDash container is 1GB of allocated memory, allowing sufficient headroom for both the Astro Node server and the isolated plugin processes.\n\n**Can I self-host EmDash CMS without Cloudflare?**\n\nYes. EmDash provides an Astro Node adapter, allowing you to deploy the CMS as a standalone Node.js server in a Docker container on any Linux host.\n\n**Does EmDash CMS require a passkey to login?**\n\nYes. EmDash uses WebAuthn passkeys by default. Your self-hosted instance must have a valid HTTPS certificate and matching origin URL for authentication to succeed.\n\n**What database does a self-hosted EmDash deployment use?**\n\nEmDash supports SQLite for local setups and PostgreSQL for production Docker deployments. PostgreSQL is recommended to prevent write locks.\n\n*Originally published at [linuxcore.dev](https://linuxcore.dev/astro/self-host-emdash-cms-astro-homelab-guide/).*", "url": "https://wpnews.pro/news/self-host-emdash-cms-docker-guide-for-homelab-servers", "canonical_source": "https://dev.to/linuxcore/self-host-emdash-cms-docker-guide-for-homelab-servers-2gkm", "published_at": "2026-12-04 23:42:03+00:00", "updated_at": "2026-12-04 23:44:01.841188+00:00", "lang": "en", "topics": ["ai-tools", "agent-protocols", "ai-infrastructure", "developer-tools"], "entities": ["Cloudflare", "EmDash CMS", "Astro", "Node.js", "PostgreSQL", "Docker", "Model Context Protocol", "workerd"], "also_reported_by": [], "takeaway": "Self-hosting EmDash on Node 24 instead of Node 22 yielded roughly 38 percent more throughput under load, and setting NODE_OPTIONS=--max-old-space-size=4096 prevents the Astro/Vite build from crashing.", "recommendation": {"advice": "When self-hosting EmDash in Docker, raise Node's heap to 4096MB for the Astro build, use PostgreSQL over SQLite for concurrent writes, and budget memory for the sandboxed workerd plugin process.", "playbook": "production-ops", "playbook_url": "https://wpnews.pro/playbooks/production-ops"}, "alternates": {"html": "https://wpnews.pro/news/self-host-emdash-cms-docker-guide-for-homelab-servers", "markdown": "https://wpnews.pro/news/self-host-emdash-cms-docker-guide-for-homelab-servers.md", "text": "https://wpnews.pro/news/self-host-emdash-cms-docker-guide-for-homelab-servers.txt", "jsonld": "https://wpnews.pro/news/self-host-emdash-cms-docker-guide-for-homelab-servers.jsonld"}}