sim icon indicating copy to clipboard operation
sim copied to clipboard

[REQUEST] Full VPS deployment guide with Docker Compose — cover Ollama, Copilot, AI Agent, SignIn/Signup issues, ..

Open synguyen97 opened this issue 4 months ago • 6 comments

Is your feature request related to a problem? Please describe: I'm self-hosting Sim Studio on a VPS using Docker Compose. While the app launches (port 3000 working), key features like Copilot, AI Agent, Ollama integration, and even login flow are broken or inconsistent. The current README lacks necessary guidance for production/VPS environments—particularly how to configure these advanced components properly.

Describe the solution you'd like: Please add a new "Production / VPS Setup" section in documentation (README or docs folder) that walks through:

  • Installing prerequisites: Docker, Docker Compose, nginx (as reverse proxy), and certbot
  • Example .env file explaining important vars (DATABASE_URL, BETTER_AUTH_URL, BETTER_AUTH_SECRET, OLLAMA_HOST, etc.)
  • Modifying docker-compose.prod.yml, including enabling Ollama via profiles (local-gpu / local-cpu)
  • Example Nginx reverse proxy config for:
    • HTTP(S) routing to 3000
    • WebSocket proxy to 3002 (Socket.io)
  • Steps to pull Ollama models (./apps/sim/scripts/ollama_docker.sh pull ...) and ensure Sim UI loads those models
  • Troubleshooting login capture:
    • How to configure migrations and migrations container run ordering
    • Handling CORS, WebSocket connection failures (e.g. socket.io / wss://)
  • Failfast checks:
    • Logs that indicate Copilot or AI Agent readiness
    • Common errors and console/network debugging tips

Describe alternatives you've considered: I attempted to setup using only docker-compose.prod.yml, .env, and docker compose up, but had to hunt across Discord and logs to piece together missing steps. I also tried overriding .env locally and proxy manually — it's non-deterministic and error-prone.

Thanks for considering — love Sim Studio, just want to make the deployment process smoother!

synguyen97 avatar Aug 07 '25 07:08 synguyen97

Interesting

bitchzoom avatar Aug 07 '25 13:08 bitchzoom

@synguyen97 would you be so kind as to share what you've learned so far perhaps?

Chinoman10 avatar Sep 21 '25 14:09 Chinoman10

I have finally worked out the kinks - this covered many of the other issues in this repo - and got my own instance running well in Portainer. I had to modify the compose file quite a bit, and diagnose the websocket connection silently failing (nginx reverse proxy needs to redirect /socket.io/ to the other port) among other things.

name: sim-with-ollama

services:
  # Main Sim Studio Application
  simstudio:
    image: ghcr.io/simstudioai/simstudio
    ports:
      - '3701:3000'
    deploy:
      resources:
        limits:
          memory: 8G
    environment:
      - DATABASE_URL=postgresql://postgres:sim@db:5432/simstudio
      - BETTER_AUTH_URL=${NEXT_PUBLIC_APP_URL}
      - NEXT_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL}
      - BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET}
      - ENCRYPTION_KEY=${ENCRYPTION_KEY}
      - COPILOT_API_KEY=${COPILOT_API_KEY}
      - SIM_AGENT_API_URL=${SIM_AGENT_API_URL}
      - OLLAMA_URL=http://ollama:3704
      - NEXT_PUBLIC_SOCKET_URL=${NEXT_PUBLIC_SOCKET_URL}
    depends_on:
      db:
        condition: service_healthy
      migrations:
        condition: service_completed_successfully
      realtime:
        condition: service_healthy
    healthcheck:
      test: ['CMD', 'wget', '--spider', '--quiet', 'http://127.0.0.1:3000']
      interval: 90s
      timeout: 5s
      retries: 3
      start_period: 10s
    restart: unless-stopped

  # Realtime Socket Server
  realtime:
    image: ghcr.io/simstudioai/realtime
    environment:
      - DATABASE_URL=postgresql://postgres:sim@db:5432/simstudio
      - NEXT_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL}
      - BETTER_AUTH_URL=${NEXT_PUBLIC_APP_URL}
      - BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET}
      - NODE_ENV=development
    depends_on:
      db:
        condition: service_healthy
    restart: unless-stopped
    ports:
      - '3702:3002'
    deploy:
      resources:
        limits:
          memory: 8G
    healthcheck:
      test: ['CMD', 'wget', '--spider', '--quiet', 'http://127.0.0.1:3002/health']
      interval: 90s
      timeout: 5s
      retries: 3
      start_period: 10s
  
  # Database Migrations
  migrations:
    image: ghcr.io/simstudioai/migrations
    environment:
      - DATABASE_URL=postgresql://postgres:sim@db:5432/simstudio
    depends_on:
      db:
        condition: service_healthy
    command: ['bun', 'run', 'db:migrate']
    restart: 'no'

  # PostgreSQL Database with Vector Extension
  db:
    image: pgvector/pgvector:pg17
    restart: always
    ports:
      - '3703:5432'
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=sim
      - POSTGRES_DB=simstudio
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U postgres']
      interval: 5s
      timeout: 5s
      retries: 5

  # Ollama CPU-only version
  ollama:
    image: ollama/ollama:latest
    pull_policy: always
    volumes:
      - ollama_data:/root/.ollama
    ports:
      - '3704:3704'
    environment:
      - OLLAMA_LOAD_TIMEOUT=-1
      - OLLAMA_KEEP_ALIVE=-1
      - OLLAMA_DEBUG=1
      - OLLAMA_HOST=0.0.0.0:3704
    command: 'serve'
    healthcheck:
      test: ['CMD', 'ollama', 'list']
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 30s
    restart: unless-stopped
    networks:
      default:

  # Helper container to pull models automatically
  model-setup:
    image: ollama/ollama:latest
    profiles:
      - setup
    volumes:
      - ollama_data:/root/.ollama
    environment:
      - OLLAMA_HOST=ollama:3704
    entrypoint: ["/bin/sh", "-lc"]
    command: >
      sh -c "
        echo 'Waiting for Ollama to be ready...' &&
        until ollama list >/dev/null 2>&1; do echo 'Waiting for Ollama...'; sleep 2; done &&
        echo 'Pulling gemma3:4b model (recommended starter model)...' &&
        ollama pull gemma3:4b &&
        echo 'Model setup complete! You can now use gemma3:4b in Sim.' &&
        echo 'To add more models, run: docker compose -f docker-compose.ollama.yml exec ollama ollama pull <model-name>'
      "
    restart: 'no'



volumes:
  postgres_data:
  ollama_data:

Erudition avatar Sep 23 '25 05:09 Erudition

@Erudition can you create an account with this recipe? Because I couldn't. Please check the issue #1243

orkutmuratyilmaz avatar Oct 01 '25 06:10 orkutmuratyilmaz

I couldn't at first, but I don't remember what I did to fix that unfortunately. It wasn't related to the recipe, but to clearing the state or SSL setup I think.

Erudition avatar Oct 16 '25 22:10 Erudition

thanks for the explanation. I'll try it soon.

orkutmuratyilmaz avatar Oct 22 '25 05:10 orkutmuratyilmaz