deployment
Original:🇺🇸 English
Translated
Deploy ContextVM servers and clients in production environments. Use when setting up production deployments, configuring Docker containers, managing environment variables, choosing relay configurations, or monitoring running services.
17installs
Sourcecontextvm/cvmi
Added on
NPX Install
npx skill4agent add contextvm/cvmi deploymentTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →ContextVM Deployment
Deploy ContextVM servers and clients in production environments.
Environment Variables
Required
| Variable | Description | Example |
|---|---|---|
| Server's Nostr private key (hex) | |
| Client's Nostr private key (hex) | |
Optional
| Variable | Description | Default |
|---|---|---|
| Comma-separated relay URLs | |
| Logging verbosity | |
| Where to write logs | |
| Log file path (if destination=file) | - |
| | |
Docker Deployment
Basic Server Container
dockerfile
FROM oven/bun:alpine
WORKDIR /app
COPY package.json bun.lock ./
RUN bun install --frozen-lockfile
COPY . .
ENV SERVER_PRIVATE_KEY=""
ENV RELAYS="wss://relay.contextvm.org,wss://cvm.otherstuff.ai"
ENV LOG_LEVEL="info"
EXPOSE 3000
CMD ["bun", "run", "server.ts"]Docker Compose
yaml
version: "3.8"
services:
cvm-server:
build: .
environment:
- SERVER_PRIVATE_KEY=${SERVER_PRIVATE_KEY}
- RELAYS=wss://relay.contextvm.org,wss://cvm.otherstuff.ai
- LOG_LEVEL=info
- ENCRYPTION_MODE=optional
restart: unless-stopped
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"See for complete example.
assets/docker-compose.ymlRelay Configuration
Recommended Public Relays
wss://relay.contextvm.org
wss://cvm.otherstuff.ai
wss://nos.lolProduction Considerations
- Use 3-5 relays for redundancy
- Include at least 2 geographically distributed
- Monitor relay uptime
- Have backup relay list ready
Private Relay Setup
For sensitive deployments:
typescript
const relayPool = new ApplesauceRelayPool([
"wss://private-relay.your-domain.com",
]);Security Best Practices
Key Management
✓ DO:
- Store keys in environment variables
- Use secret management, if the security of the server requires it (AWS Secrets Manager, HashiCorp Vault)
✗ DON'T:
- Hardcode keys in source
- Commit keys to version control
- Log private keys
- Share keys between services
Access Control
typescript
// Whitelist specific clients
const transport = new NostrServerTransport({
signer,
relayHandler: relayPool,
allowedPublicKeys: [
process.env.CLIENT_1_PUBKEY!,
process.env.CLIENT_2_PUBKEY!,
],
});Health Checks
Server Health Check
typescript
async function healthCheck(server: McpServer): Promise<boolean> {
try {
// Check if server responds to ping
await server.ping();
return true;
} catch {
return false;
}
}Docker Health Check
dockerfile
HEALTHCHECK \
CMD bun run healthcheck.ts || exit 1Monitoring
Structured Logging
typescript
import { createLogger } from "@contextvm/sdk/core";
const logger = createLogger("server");
// Production log format
logger.info("request.completed", {
module: "server",
method: "tools/call",
tool: "echo",
clientPubkey: pubkey.slice(0, 8) + "...",
durationMs: 45,
});Metrics to Track
- Request rate and latency
- Error rate by type
- Active connections
- Relay connection status
- Event publish/subscribe rates
See for detailed monitoring setup.
references/monitoring.mdProduction Checklist
- Keys in environment/secrets manager
- Logging configured appropriately
- Health checks implemented
- Error handling in place
- Graceful shutdown handling
- Resource limits set (Docker)
- Monitoring/alerting configured