services: ollama: image: ollama/ollama ports: - "11434:11434" volumes: - ollama_data:/root/.ollama # model files persist across restarts - ./ollama-entrypoint.sh:/entrypoint.sh entrypoint: ["/bin/sh", "/entrypoint.sh"] environment: - MODEL=${MODEL:-qwen3:4b} healthcheck: test: ["CMD-SHELL", "ollama list | grep -q ${MODEL:-qwen3:4b}"] interval: 15s timeout: 5s retries: 120 # first-time model pull (~5 GB) can take 20+ minutes start_period: 30s backend: build: ./backend ports: - "8000:8000" depends_on: ollama: condition: service_healthy # waits until model is ready, not just server up env_file: - .env volumes: - ./backend:/app # live reload during dev frontend: build: ./frontend ports: - "8501:8501" depends_on: - backend env_file: - .env volumes: - ./frontend:/app # live reload during dev volumes: ollama_data: # named volume so model survives docker compose down