Skip to content

Docker Deployment

ByteMCP includes a production-ready Dockerfile with multi-stage builds.

Terminal window
docker build -t bytemcp .
Terminal window
docker run -d \
--name bytemcp \
-p 3000:3000 \
--env-file .env \
bytemcp

The included Dockerfile uses a multi-stage build:

# Stage 1: Build
FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production=false
COPY . .
RUN npm run build
# Stage 2: Runtime
FROM node:18-alpine
RUN apk add --no-cache dumb-init
WORKDIR /app
RUN addgroup -g 1001 nodejs && adduser -u 1001 -G nodejs -s /bin/sh -D nodejs
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./
USER nodejs
EXPOSE 3000
ENV MCP_MODE=remote
ENTRYPOINT ["dumb-init", "--"]
CMD ["node", "dist/index.js"]
  • Multi-stage build - Smaller final image
  • Non-root user - Security best practice
  • dumb-init - Proper signal handling
  • Alpine base - Minimal footprint

For development with database:

version: '3.8'
services:
bytemcp:
build: .
ports:
- "3000:3000"
environment:
- MCP_MODE=remote
- DB_HOST=db
- DB_DATABASE=bytefederal
- DB_USER=bytemcp
- DB_PASSWORD=secret
depends_on:
- db
db:
image: mysql:8.0
environment:
- MYSQL_DATABASE=bytefederal
- MYSQL_USER=bytemcp
- MYSQL_PASSWORD=secret
- MYSQL_ROOT_PASSWORD=rootsecret
volumes:
- db_data:/var/lib/mysql
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
volumes:
db_data:

Run with:

Terminal window
docker-compose up -d

Pass via --env-file or -e:

Terminal window
# Using env file
docker run --env-file .env bytemcp
# Using individual variables
docker run \
-e DB_HOST=db.example.com \
-e DB_DATABASE=bytefederal \
-e DB_USER=user \
-e DB_PASSWORD=pass \
-e MCP_MODE=remote \
bytemcp

Add health checks to your container:

healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
Terminal window
docker run \
--network host \
--env-file .env \
bytemcp

Or specify the database host explicitly:

Terminal window
docker run \
-e DB_HOST=host.docker.internal \
-e DB_DATABASE=bytefederal \
...
bytemcp
deploy:
resources:
limits:
cpus: '1.0'
memory: 512M
reservations:
cpus: '0.5'
memory: 256M
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
restart: unless-stopped

Basic deployment manifest:

apiVersion: apps/v1
kind: Deployment
metadata:
name: bytemcp
spec:
replicas: 2
selector:
matchLabels:
app: bytemcp
template:
metadata:
labels:
app: bytemcp
spec:
containers:
- name: bytemcp
image: bytemcp:latest
ports:
- containerPort: 3000
envFrom:
- secretRef:
name: bytemcp-secrets
livenessProbe:
httpGet:
path: /health
port: 3000
initialDelaySeconds: 10
periodSeconds: 30