satyakimitra commited on
Commit
c12313c
·
1 Parent(s): 1b3a7fa

Fix Dockerfile CMD syntax

Browse files
Files changed (1) hide show
  1. Dockerfile +7 -50
Dockerfile CHANGED
@@ -1,21 +1,15 @@
1
- # Use Python 3.11 for better performance and compatibility
2
  FROM python:3.11-slim
3
 
4
- # Set working directory
5
  WORKDIR /app
6
 
7
  # Install system dependencies
8
  RUN apt-get update && apt-get install -y \
9
  curl \
10
  wget \
11
- git \
12
- build-essential \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
- # Copy requirements first for better caching
16
  COPY requirements.txt .
17
-
18
- # Install Python dependencies
19
  RUN pip install --no-cache-dir -r requirements.txt
20
 
21
  # Download spaCy model
@@ -24,51 +18,14 @@ RUN python -m spacy download en_core_web_sm
24
  # Install Ollama
25
  RUN curl -fsSL https://ollama.ai/install.sh | sh
26
 
27
- # Copy application code
28
  COPY . .
29
 
30
- # Create necessary directories
31
- RUN mkdir -p uploads cache logs cache/models models
32
-
33
- # Download pre-trained models using a script file instead of inline Python
34
- RUN python -c "\
35
- import sys;\
36
- sys.path.append('/app');\
37
- try:\
38
- from model_manager.model_loader import ModelLoader;\
39
- import logging;\
40
- logging.basicConfig(level=logging.INFO);\
41
- print('Pre-downloading AI models...');\
42
- loader = ModelLoader();\
43
- loader.ensure_models_downloaded();\
44
- print('All models downloaded successfully!');\
45
- except Exception as e:\
46
- print(f'Model download warning: {e}');\
47
- print('Models will be downloaded on first use...');\
48
- "
49
 
50
- # Expose port (required for Hugging Face Spaces)
51
  EXPOSE 7860
52
 
53
- # Health check
54
- HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
55
- CMD curl -f http://localhost:7860/health || exit 1
56
-
57
- # Start the application
58
- CMD ["sh", "-c", "
59
- # Start Ollama server in background
60
- echo 'Starting Ollama server...'
61
- ollama serve &
62
-
63
- # Wait for Ollama to start
64
- echo 'Waiting for Ollama to start...'
65
- sleep 15
66
-
67
- # Ensure the model is pulled
68
- echo 'Checking for Ollama model...'
69
- ollama pull llama3:8b &
70
-
71
- # Start the FastAPI application
72
- echo 'Starting AI Contract Risk Analyzer...'
73
- uvicorn app:app --host 0.0.0.0 --port 7860
74
- "]
 
 
1
  FROM python:3.11-slim
2
 
 
3
  WORKDIR /app
4
 
5
  # Install system dependencies
6
  RUN apt-get update && apt-get install -y \
7
  curl \
8
  wget \
 
 
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
+ # Copy requirements and install
12
  COPY requirements.txt .
 
 
13
  RUN pip install --no-cache-dir -r requirements.txt
14
 
15
  # Download spaCy model
 
18
  # Install Ollama
19
  RUN curl -fsSL https://ollama.ai/install.sh | sh
20
 
21
+ # Copy application
22
  COPY . .
23
 
24
+ # Create directories
25
+ RUN mkdir -p uploads cache logs
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
+ # Expose port
28
  EXPOSE 7860
29
 
30
+ # Simple CMD - start Ollama in background, then start FastAPI
31
+ CMD ollama serve & sleep 20 && ollama pull llama3:8b & uvicorn app:app --host 0.0.0.0 --port 7860