Spaces:
Sleeping
Sleeping
File size: 4,652 Bytes
0452a50 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# Docker Setup Guide for IntegraChat
## Quick Start
### Option 1: Use PowerShell Script (Easiest for Windows)
```powershell
# Run the helper script
.\run-docker.ps1
```
### Option 2: Build and Run with Docker Compose (Recommended)
```powershell
# PowerShell
docker-compose up -d
# Or with rebuild
docker-compose up -d --build
```
### Build and Run Manually
**PowerShell (Windows):**
```powershell
# Build the image
docker build -t integrachat:latest .
# Run the container (PowerShell uses backticks for line continuation)
docker run -d --name integrachat `
-p 7860:7860 -p 8000:8000 -p 8900:8900 `
-e DOCKER_CONTAINER=1 `
integrachat:latest
# Or use a single line:
docker run -d --name integrachat -p 7860:7860 -p 8000:8000 -p 8900:8900 -e DOCKER_CONTAINER=1 integrachat:latest
```
**Bash/Linux/Mac:**
```bash
# Build the image
docker build -t integrachat:latest .
# Run the container
docker run -d --name integrachat \
-p 7860:7860 -p 8000:8000 -p 8900:8900 \
-e DOCKER_CONTAINER=1 \
integrachat:latest
```
## Container Management
### View Logs
```bash
# All logs (streaming)
docker logs -f integrachat
# Specific service logs
docker exec integrachat tail -f /app/logs/fastapi.log
docker exec integrachat tail -f /app/logs/gradio.log
docker exec integrachat tail -f /app/logs/mcp.log
```
### Stop Container
```bash
docker stop integrachat
```
### Start Container
```bash
docker start integrachat
```
### Remove Container
```bash
docker stop integrachat
docker rm integrachat
```
### Rebuild After Changes
**PowerShell:**
```powershell
docker stop integrachat
docker rm integrachat
docker build -t integrachat:latest .
docker run -d --name integrachat -p 7860:7860 -p 8000:8000 -p 8900:8900 -e DOCKER_CONTAINER=1 integrachat:latest
```
**Bash:**
```bash
docker stop integrachat
docker rm integrachat
docker build -t integrachat:latest .
docker run -d --name integrachat \
-p 7860:7860 -p 8000:8000 -p 8900:8900 \
-e DOCKER_CONTAINER=1 \
integrachat:latest
```
## Access Services
- **Gradio UI**: http://localhost:7860
- **FastAPI API**: http://localhost:8000
- **MCP Server**: http://localhost:8900
- **API Docs**: http://localhost:8000/docs
- **MCP Docs**: http://localhost:8900/docs
## Environment Variables
Create a `.env` file (or use docker-compose.yml) to configure:
```env
# LLM Configuration
LLM_BACKEND=groq # or "ollama"
GROQ_API_KEY=your_key_here
GROQ_MODEL=llama-3.1-8b-instant
# Supabase (optional - for analytics)
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_SERVICE_KEY=your_service_key
# Ports (defaults shown)
API_PORT=8000
MCP_PORT=8900
GRADIO_PORT=7860
```
## Docker Compose
The `docker-compose.yml` file provides:
- Easy service management
- Environment variable support
- Volume mounting for logs
- Health checks
- Auto-restart on failure
### Using Docker Compose
```bash
# Start services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down
# Rebuild and restart
docker-compose up -d --build
```
## PowerShell-Specific Notes
### Line Continuation
PowerShell uses backticks (`` ` ``) for line continuation, not backslashes (`\`):
```powershell
# ✅ Correct (PowerShell)
docker run -d --name integrachat `
-p 7860:7860 `
-p 8000:8000 `
integrachat:latest
# ✅ Also correct (single line)
docker run -d --name integrachat -p 7860:7860 -p 8000:8000 -p 8900:8900 -e DOCKER_CONTAINER=1 integrachat:latest
# ❌ Wrong (bash syntax - doesn't work in PowerShell)
docker run -d --name integrachat \
-p 7860:7860 \
integrachat:latest
```
### Quick Commands Script
Use `run-docker.ps1` for easy container management:
```powershell
.\run-docker.ps1
```
## Troubleshooting
### Check Container Status
```bash
docker ps -a | grep integrachat
```
### Check Service Health
```bash
# FastAPI health
curl http://localhost:8000/health
# MCP health
curl http://localhost:8900/health
```
### View All Logs
```bash
docker exec integrachat tail -n 100 /app/logs/*.log
```
### Restart Services Inside Container
```bash
# Container will auto-restart services, but you can manually restart:
docker restart integrachat
```
### Clean Up
```bash
# Remove container and image
docker stop integrachat
docker rm integrachat
docker rmi integrachat:latest
# Remove all unused Docker resources
docker system prune -a
```
## Notes
- The container runs all three services (MCP, FastAPI, Gradio) automatically
- Logs are written to `/app/logs/` inside the container
- The entrypoint script handles service startup and health checks
- Supabase warnings are expected if credentials are not configured (analytics will be disabled gracefully)
|