# Docker Deployment Guide
This guide covers deployment options for the TDZ C64 Knowledge Base MCP server and Streamlit GUI.
## π€ Important Considerations
### MCP Servers Are Typically Local
- MCP servers communicate via **stdio** (standard input/output), not HTTP
- They're designed to run **locally** and connect to Claude Desktop/Code
- Hosting them in the cloud requires additional work (HTTP wrapper)
- **Best practice:** Run MCP server locally, optionally host GUI in cloud
### Two Deployment Scenarios
1. **Local Docker Deployment** - Easy setup for local use
2. **Cloud Deployment** - Host Streamlit GUI online for remote access
---
## π³ Option 1: Docker for Local Deployment (Recommended)
Create a Docker image for one-command setup.
### Benefits
- β
Consistent environment across machines
- β
Easy distribution to other users
- β
No cloud costs
- β
MCP servers work best locally anyway
- β
Full control over data
### Use Cases
- Personal knowledge base
- Sharing with other C64 enthusiasts
- Development and testing
- Offline usage
### Implementation Plan
```dockerfile
# Dockerfile example structure
FROM python:3.10-slim
WORKDIR /app
COPY . .
RUN pip install -e ".[dev,gui,semantic]"
EXPOSE 8501
CMD ["streamlit", "run", "admin_gui.py"]
```
---
## βοΈ Option 2: Cloud Deployment
Host the Streamlit GUI online for remote access.
### π₯ Fly.io (Best for Full Deployment)
**Free Tier:**
- 3 shared-cpu VMs
- 3GB persistent storage
- 160GB bandwidth/month
**Pros:**
- β
Persistent volumes (SQLite database persists)
- β
Always-on (no cold starts)
- β
Can run both MCP server + GUI
- β
Simple deployment (`fly launch`)
- β
Custom domains supported
**Cons:**
- β οΈ Free tier more limited than before
- β οΈ Requires credit card for verification
**Best For:** Personal knowledge base with persistent data
**Deployment:**
```bash
# Install flyctl
curl -L https://fly.io/install.sh | sh
# Launch app
fly launch
# Deploy
fly deploy
```
---
### π₯ Google Cloud Run (Best for GUI Only)
**Free Tier:**
- 2 million requests/month
- 360,000 GB-seconds/month
- 1GB network egress/month
**Pros:**
- β
Very generous free tier
- β
Auto-scaling (scales to zero)
- β
Fast deployment
- β
Google Cloud integration
**Cons:**
- β οΈ Cold starts (first request after idle)
- β οΈ Need Cloud Storage/Cloud SQL for persistence
- β οΈ More complex for stateful apps
**Best For:** Public-facing GUI with separate database
**Deployment:**
```bash
# Build and deploy
gcloud run deploy tdz-c64-knowledge \
--source . \
--platform managed \
--region us-central1 \
--allow-unauthenticated
```
---
### π₯ Render
**Free Tier:**
- 750 hours/month
- 100GB bandwidth/month
- Automatic deploys from GitHub
**Pros:**
- β
Easy setup with GitHub integration
- β
Automatic HTTPS
- β
Free PostgreSQL database (for 90 days)
**Cons:**
- β οΈ Spins down after 15min inactivity
- β οΈ Slow cold starts (30-60 seconds)
- β οΈ Limited to 750 hours/month
**Best For:** Demo deployments or low-traffic usage
**Deployment:**
- Connect GitHub repo
- Select "Web Service"
- Build command: `pip install -e ".[gui]"`
- Start command: `streamlit run admin_gui.py --server.port $PORT`
---
### ποΈ AWS Free Tier (ECS/Fargate)
**Free Tier (12 months):**
- 750 hours/month of t2.micro
- 5GB storage
- Limited data transfer
**Pros:**
- β
Professional-grade infrastructure
- β
Great for learning AWS
- β
Many integration options
**Cons:**
- β οΈ Complex setup
- β οΈ Free tier expires after 12 months
- β οΈ Easy to accidentally incur charges
**Best For:** Learning AWS or enterprise deployments
---
### π· Azure Container Instances
**Free Tier:**
- Pay-as-you-go (very limited free tier)
- $200 credit for first 30 days
**Pros:**
- β
Simple container deployment
- β
Windows/Linux support
- β
Microsoft ecosystem integration
**Cons:**
- β οΈ Not very generous free tier
- β οΈ Can get expensive quickly
**Best For:** Microsoft-centric environments
---
### β‘ Railway (Previously Popular)
**Free Tier:**
- $5/month credit (previously unlimited)
- Execution time limits
**Status:**
- β οΈ Significantly reduced free tier in 2023
- β οΈ $5/month doesn't go far
- β οΈ No longer recommended for free hosting
---
## π Comparison Table
| Service | Free Tier | Persistent Storage | Always-On | Best For |
|---------|-----------|-------------------|-----------|----------|
| **Fly.io** | 3 VMs, 3GB | β
Yes (volumes) | β
Yes | Personal use |
| **Google Cloud Run** | 2M req/mo | β οΈ Separate service | β No (scales to 0) | GUI only |
| **Render** | 750 hrs/mo | β οΈ Spins down | β No (15min idle) | Demos |
| **AWS** | 750 hrs/mo (12mo) | β
Yes (EBS) | β
Yes | Learning AWS |
| **Azure** | Very limited | β
Yes | β
Yes | Microsoft shops |
| **Railway** | $5/mo credit | β
Yes | β οΈ Limited | Not recommended |
| **Local Docker** | Unlimited | β
Yes | β
Yes | **Best choice** |
---
## π‘ Recommendations by Use Case
### Personal Use (Recommended)
**β Local Docker Deployment**
- No costs
- Full control
- Best performance
- MCP integration works perfectly
### Share with Friends
**β Fly.io Deployment**
- Persistent storage
- Always available
- Simple URL to share
- Free tier sufficient
### Public Demo
**β Google Cloud Run**
- Generous free tier
- Auto-scaling
- Professional appearance
- Can handle traffic spikes
### Production/Enterprise
**β AWS or Azure**
- Professional infrastructure
- Compliance options
- Advanced features
- Support available
---
## π Next Steps
### For Local Docker Deployment:
1. Create Dockerfile
2. Create docker-compose.yml (with volume mounts)
3. Add .dockerignore
4. Build and test image
5. Publish to Docker Hub (optional)
### For Cloud Deployment:
1. Choose platform (Fly.io recommended)
2. Set up account
3. Configure persistent storage
4. Set environment variables
5. Deploy and test
### For Both:
1. Document deployment process
2. Create deployment scripts
3. Set up CI/CD (GitHub Actions)
4. Add health checks
5. Monitor and maintain
---
## π Notes
- SQLite database needs persistent storage in cloud deployments
- Consider using PostgreSQL for cloud deployments (better concurrency)
- Environment variables needed: `USE_FTS5=1`, `USE_SEMANTIC_SEARCH=1`
- Semantic search embeddings can be large (factor into storage/memory)
- First-time semantic search will take time to build embeddings
---
## π Useful Resources
- [Fly.io Documentation](https://fly.io/docs/)
- [Google Cloud Run Documentation](https://cloud.google.com/run/docs)
- [Render Documentation](https://render.com/docs)
- [Docker Documentation](https://docs.docker.com/)
- [Streamlit Deployment Guide](https://docs.streamlit.io/streamlit-community-cloud/deploy-your-app)
---
*Last updated: 2025-12-13*