File size: 2,040 Bytes
0fa4cc9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
version: '3.8'

# Load environment variables from .env file
x-env: &env
  env_file: .env
  environment:
    - OLLAMA_PORT=${OLLAMA_PORT:-11434}
    - OLLAMA_HOST=${OLLAMA_HOST:-0.0.0.0}
    - STREAMLIT_SERVER_PORT=${STREAMLIT_SERVER_PORT:-8501}
    - STREAMLIT_SERVER_ADDRESS=${STREAMLIT_SERVER_ADDRESS:-0.0.0.0}
    - DEFAULT_MODEL=${DEFAULT_MODEL:-mistral:7b-instruct}

services:
  # Ollama - LLM Engine (minimalna konfiguracja)
  ollama:
    image: ollama/ollama:latest
    container_name: ollama-engine
    <<: *env
    ports:
      - "${OLLAMA_PORT:-11434}:11434"
    volumes:
      - ollama_data:/root/.ollama
    # deploy:
      # resources:
        # reservations:
          # devices:
            # - driver: nvidia
              # count: 1
              # capabilities: [gpu]
    restart: unless-stopped

  # Streamlit UI (Python frontend)
  streamlit-ui:
    build: .
    container_name: llm-ui
    <<: *env
    ports:
      - "${STREAMLIT_SERVER_PORT:-8501}:8501"
    depends_on:
      - ollama
    environment:
      - OLLAMA_URL=http://ollama:${OLLAMA_PORT:-11434}
      - STREAMLIT_SERVER_PORT=${STREAMLIT_SERVER_PORT:-8501}
      - STREAMLIT_SERVER_ADDRESS=${STREAMLIT_SERVER_ADDRESS:-0.0.0.0}
    restart: unless-stopped
    volumes:
      - ./app:/app
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:${STREAMLIT_SERVER_PORT:-8501}/_stcore/health"]
      interval: 30s
      timeout: 10s
      retries: 3

  # Model Setup (inicjalizacja modelu)
  model-setup:
    image: ollama/ollama:latest
    container_name: model-setup
    <<: *env
    depends_on:
      - ollama
    volumes:
      - ollama_data:/root/.ollama
    environment:
      - OLLAMA_HOST=http://ollama:${OLLAMA_PORT:-11434}
      - DEFAULT_MODEL=${DEFAULT_MODEL:-mistral:7b-instruct}
    command: >
      sh -c "
        echo 'Waiting for Ollama to be ready...' &&
        sleep 10 &&
        ollama pull ${DEFAULT_MODEL:-mistral:7b-instruct} &&
        echo 'Model loaded successfully!'
      "
    restart: "no"

volumes:
  ollama_data: