|
| 1 | +--- |
| 2 | +title: Docker |
| 3 | +description: Deploy Sim Studio with Docker Compose |
| 4 | +--- |
| 5 | + |
| 6 | +import { Tab, Tabs } from 'fumadocs-ui/components/tabs' |
| 7 | +import { Callout } from 'fumadocs-ui/components/callout' |
| 8 | + |
| 9 | +## Quick Start |
| 10 | + |
| 11 | +```bash |
| 12 | +# Clone and start |
| 13 | +git clone https://github.com/simstudioai/sim.git && cd sim |
| 14 | +docker compose -f docker-compose.prod.yml up -d |
| 15 | +``` |
| 16 | + |
| 17 | +Open [http://localhost:3000](http://localhost:3000) |
| 18 | + |
| 19 | +## Production Setup |
| 20 | + |
| 21 | +### 1. Configure Environment |
| 22 | + |
| 23 | +```bash |
| 24 | +# Generate secrets |
| 25 | +cat > .env << EOF |
| 26 | +DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio |
| 27 | +BETTER_AUTH_SECRET=$(openssl rand -hex 32) |
| 28 | +ENCRYPTION_KEY=$(openssl rand -hex 32) |
| 29 | +INTERNAL_API_SECRET=$(openssl rand -hex 32) |
| 30 | +NEXT_PUBLIC_APP_URL=https://sim.yourdomain.com |
| 31 | +BETTER_AUTH_URL=https://sim.yourdomain.com |
| 32 | +NEXT_PUBLIC_SOCKET_URL=https://sim.yourdomain.com |
| 33 | +EOF |
| 34 | +``` |
| 35 | + |
| 36 | +### 2. Start Services |
| 37 | + |
| 38 | +```bash |
| 39 | +docker compose -f docker-compose.prod.yml up -d |
| 40 | +``` |
| 41 | + |
| 42 | +### 3. Set Up SSL |
| 43 | + |
| 44 | +<Tabs items={['Caddy (Recommended)', 'Nginx + Certbot']}> |
| 45 | + <Tab value="Caddy (Recommended)"> |
| 46 | +Caddy automatically handles SSL certificates. |
| 47 | + |
| 48 | +```bash |
| 49 | +# Install Caddy |
| 50 | +sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl |
| 51 | +curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg |
| 52 | +curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list |
| 53 | +sudo apt update && sudo apt install caddy |
| 54 | +``` |
| 55 | + |
| 56 | +Create `/etc/caddy/Caddyfile`: |
| 57 | +``` |
| 58 | +sim.yourdomain.com { |
| 59 | + reverse_proxy localhost:3000 |
| 60 | +
|
| 61 | + handle /socket.io/* { |
| 62 | + reverse_proxy localhost:3002 |
| 63 | + } |
| 64 | +} |
| 65 | +``` |
| 66 | + |
| 67 | +```bash |
| 68 | +sudo systemctl restart caddy |
| 69 | +``` |
| 70 | + </Tab> |
| 71 | + <Tab value="Nginx + Certbot"> |
| 72 | +```bash |
| 73 | +# Install |
| 74 | +sudo apt install nginx certbot python3-certbot-nginx -y |
| 75 | + |
| 76 | +# Create /etc/nginx/sites-available/sim |
| 77 | +server { |
| 78 | + listen 80; |
| 79 | + server_name sim.yourdomain.com; |
| 80 | + |
| 81 | + location / { |
| 82 | + proxy_pass http://127.0.0.1:3000; |
| 83 | + proxy_http_version 1.1; |
| 84 | + proxy_set_header Upgrade $http_upgrade; |
| 85 | + proxy_set_header Connection 'upgrade'; |
| 86 | + proxy_set_header Host $host; |
| 87 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 88 | + } |
| 89 | + |
| 90 | + location /socket.io/ { |
| 91 | + proxy_pass http://127.0.0.1:3002; |
| 92 | + proxy_http_version 1.1; |
| 93 | + proxy_set_header Upgrade $http_upgrade; |
| 94 | + proxy_set_header Connection "upgrade"; |
| 95 | + } |
| 96 | +} |
| 97 | + |
| 98 | +# Enable and get certificate |
| 99 | +sudo ln -s /etc/nginx/sites-available/sim /etc/nginx/sites-enabled/ |
| 100 | +sudo certbot --nginx -d sim.yourdomain.com |
| 101 | +``` |
| 102 | + </Tab> |
| 103 | +</Tabs> |
| 104 | + |
| 105 | +## Ollama |
| 106 | + |
| 107 | +```bash |
| 108 | +# With GPU |
| 109 | +docker compose -f docker-compose.ollama.yml --profile gpu --profile setup up -d |
| 110 | + |
| 111 | +# CPU only |
| 112 | +docker compose -f docker-compose.ollama.yml --profile cpu --profile setup up -d |
| 113 | +``` |
| 114 | + |
| 115 | +Pull additional models: |
| 116 | +```bash |
| 117 | +docker compose -f docker-compose.ollama.yml exec ollama ollama pull llama3.2 |
| 118 | +``` |
| 119 | + |
| 120 | +### External Ollama |
| 121 | + |
| 122 | +If Ollama runs on your host machine (not in Docker): |
| 123 | + |
| 124 | +```bash |
| 125 | +# macOS/Windows |
| 126 | +OLLAMA_URL=http://host.docker.internal:11434 docker compose -f docker-compose.prod.yml up -d |
| 127 | + |
| 128 | +# Linux - use your host IP |
| 129 | +OLLAMA_URL=http://192.168.1.100:11434 docker compose -f docker-compose.prod.yml up -d |
| 130 | +``` |
| 131 | + |
| 132 | +<Callout type="warning"> |
| 133 | + Inside Docker, `localhost` refers to the container, not your host. Use `host.docker.internal` or your host's IP. |
| 134 | +</Callout> |
| 135 | + |
| 136 | +## Commands |
| 137 | + |
| 138 | +```bash |
| 139 | +# View logs |
| 140 | +docker compose -f docker-compose.prod.yml logs -f simstudio |
| 141 | + |
| 142 | +# Stop |
| 143 | +docker compose -f docker-compose.prod.yml down |
| 144 | + |
| 145 | +# Update |
| 146 | +docker compose -f docker-compose.prod.yml pull && docker compose -f docker-compose.prod.yml up -d |
| 147 | + |
| 148 | +# Backup database |
| 149 | +docker compose -f docker-compose.prod.yml exec db pg_dump -U postgres simstudio > backup.sql |
| 150 | +``` |
0 commit comments