Deploy to Node.js
EmDash runs on any Node.js 18+ hosting platform. This guide covers deployment to common providers using SQLite and local or S3-compatible storage.
Prerequisites
Section titled “Prerequisites”- Node.js 18.17.1 or higher
- A Node.js hosting provider or VPS
Configuration
Section titled “Configuration”Configure EmDash for Node.js deployment:
import { defineConfig } from "astro/config";import node from "@astrojs/node";import emdash, { local, s3 } from "emdash/astro";import { sqlite } from "emdash/db";
export default defineConfig({ output: "server", adapter: node({ mode: "standalone" }), integrations: [ emdash({ database: sqlite({ url: "file:./data/emdash.db" }), storage: local({ directory: "./data/uploads", baseUrl: "/_emdash/api/media/file", }), }), ],});Build and Run
Section titled “Build and Run”- Build the project:
npm run build-
Initialize the database:
Terminal window npx emdash init --database ./data/emdash.db -
Start the server:
Terminal window node ./dist/server/entry.mjs
The server runs on http://localhost:4321 by default.
Production Storage
Section titled “Production Storage”For production, use S3-compatible storage instead of local filesystem:
import emdash, { s3 } from "emdash/astro";
export default defineConfig({ integrations: [ emdash({ database: sqlite({ url: `file:${process.env.DATABASE_PATH}` }), storage: s3({ endpoint: process.env.S3_ENDPOINT, bucket: process.env.S3_BUCKET, accessKeyId: process.env.S3_ACCESS_KEY_ID, secretAccessKey: process.env.S3_SECRET_ACCESS_KEY, publicUrl: process.env.S3_PUBLIC_URL, // Optional CDN URL }), }), ],});Docker
Section titled “Docker”Create a Dockerfile:
FROM node:20-alpine AS builderWORKDIR /appCOPY package*.json ./RUN npm ciCOPY . .RUN npm run build
FROM node:20-alpineWORKDIR /appCOPY --from=builder /app/dist ./distCOPY --from=builder /app/node_modules ./node_modulesCOPY --from=builder /app/package.json ./
ENV HOST=0.0.0.0ENV PORT=4321
EXPOSE 4321CMD ["node", "./dist/server/entry.mjs"]Build and run:
docker build -t my-emdash-site .docker run -p 4321:4321 -v emdash-data:/app/data my-emdash-siteEnvironment Variables
Section titled “Environment Variables”Required for Production
Section titled “Required for Production”| Variable | Description |
|---|---|
EMDASH_AUTH_SECRET | Signs session cookies and auth tokens. Generate with npx emdash auth secret. |
EMDASH_PREVIEW_SECRET | Signs preview URLs for draft content. Generate with npx emdash auth secret. |
Database and Storage
Section titled “Database and Storage”| Variable | Description | Example |
|---|---|---|
DATABASE_PATH | Path to SQLite database | /data/emdash.db |
HOST | Server host | 0.0.0.0 |
PORT | Server port | 4321 |
S3_ENDPOINT | S3 endpoint URL | https://xxx.r2.cloudflarestorage.com |
S3_BUCKET | S3 bucket name | my-media-bucket |
S3_ACCESS_KEY_ID | S3 access key | AKIA... |
S3_SECRET_ACCESS_KEY | S3 secret key | ... |
S3_PUBLIC_URL | Public URL for media | https://cdn.example.com |
Persistent Storage
Section titled “Persistent Storage”SQLite requires persistent disk storage. Ensure your hosting platform provides:
- A mounted volume or persistent disk
- Write access to the database directory
- Backup mechanisms for the database file
Health Checks
Section titled “Health Checks”Add a health check endpoint for load balancers:
export const GET = () => { return new Response("OK", { status: 200 });};Configure your platform to check /health for liveness probes.