Priyanshi Saxena commited on
Commit
f82980e
Β·
1 Parent(s): 85cb7be

fix: Docker permissions for Ollama in HuggingFace Spaces

Browse files

- Add OLLAMA_HOME environment variable pointing to /app/.ollama
- Create Ollama directory with proper permissions in startup script
- Export OLLAMA_HOME in startup script to ensure Ollama uses correct path
- Fix permission denied error when creating Ollama data directory

Files changed (1) hide show
  1. Dockerfile +14 -2
Dockerfile CHANGED
@@ -6,6 +6,7 @@ ENV PYTHONUNBUFFERED=1
6
  ENV DEBIAN_FRONTEND=noninteractive
7
  ENV OLLAMA_HOST=0.0.0.0
8
  ENV OLLAMA_PORT=11434
 
9
  ENV PYTHONPATH=/app
10
 
11
  # Set working directory
@@ -29,8 +30,10 @@ RUN pip install --no-cache-dir -r requirements.txt
29
  # Copy application code
30
  COPY . .
31
 
32
- # Create necessary directories including separated web files
33
- RUN mkdir -p logs cache templates static
 
 
34
 
35
  # Expose ports for both app and Ollama
36
  EXPOSE 7860 11434
@@ -39,6 +42,15 @@ EXPOSE 7860 11434
39
  RUN echo '#!/bin/bash\n\
40
  echo "πŸš€ Starting HuggingFace Spaces Web3 Research Co-Pilot..."\n\
41
  \n\
 
 
 
 
 
 
 
 
 
42
  # Start Ollama server in background\n\
43
  echo "πŸ“¦ Starting Ollama server..."\n\
44
  ollama serve &\n\
 
6
  ENV DEBIAN_FRONTEND=noninteractive
7
  ENV OLLAMA_HOST=0.0.0.0
8
  ENV OLLAMA_PORT=11434
9
+ ENV OLLAMA_HOME=/app/.ollama
10
  ENV PYTHONPATH=/app
11
 
12
  # Set working directory
 
30
  # Copy application code
31
  COPY . .
32
 
33
+ # Create necessary directories including Ollama data directory
34
+ RUN mkdir -p logs cache templates static $OLLAMA_HOME \
35
+ && chown -R 1000:1000 /app \
36
+ && chmod -R 755 /app
37
 
38
  # Expose ports for both app and Ollama
39
  EXPOSE 7860 11434
 
42
  RUN echo '#!/bin/bash\n\
43
  echo "πŸš€ Starting HuggingFace Spaces Web3 Research Co-Pilot..."\n\
44
  \n\
45
+ # Set Ollama environment\n\
46
+ export OLLAMA_HOME=/app/.ollama\n\
47
+ export OLLAMA_HOST=0.0.0.0\n\
48
+ export OLLAMA_PORT=11434\n\
49
+ \n\
50
+ # Ensure Ollama directory exists with correct permissions\n\
51
+ mkdir -p $OLLAMA_HOME\n\
52
+ chmod 755 $OLLAMA_HOME\n\
53
+ \n\
54
  # Start Ollama server in background\n\
55
  echo "πŸ“¦ Starting Ollama server..."\n\
56
  ollama serve &\n\