Hashii1729 commited on
Commit
11e2c0d
·
1 Parent(s): a923a38

Enhance Dockerfile and startup script: add Ollama model directories with permissions, improve logging of user and directory status in startup script

Browse files
Files changed (2) hide show
  1. Dockerfile.fastapi +11 -6
  2. fastapi_startup_script.sh +8 -0
Dockerfile.fastapi CHANGED
@@ -13,6 +13,12 @@ RUN curl -fsSL https://ollama.com/install.sh | sh
13
  # Create non-root user for security
14
  RUN groupadd -r appuser && useradd -r -g appuser -m appuser
15
 
 
 
 
 
 
 
16
  # Set working directory
17
  WORKDIR /app
18
 
@@ -26,14 +32,13 @@ COPY fast.py .
26
  COPY fastapi_startup_script.sh .
27
  RUN chmod +x fastapi_startup_script.sh
28
 
29
- # Create logs directory and Ollama directories
30
  RUN mkdir -p /app/logs && \
31
- mkdir -p /home/appuser/.ollama && \
32
- mkdir -p /home/appuser/.ollama/models
33
 
34
- # Change ownership to non-root user
35
- RUN chown -R appuser:appuser /app && \
36
- chown -R appuser:appuser /home/appuser/.ollama
37
 
38
  # Switch to non-root user
39
  USER appuser
 
13
  # Create non-root user for security
14
  RUN groupadd -r appuser && useradd -r -g appuser -m appuser
15
 
16
+ # Create Ollama directories with proper permissions
17
+ RUN mkdir -p /home/appuser/.ollama && \
18
+ mkdir -p /home/appuser/.ollama/models && \
19
+ chown -R appuser:appuser /home/appuser/.ollama && \
20
+ chmod -R 755 /home/appuser/.ollama
21
+
22
  # Set working directory
23
  WORKDIR /app
24
 
 
32
  COPY fastapi_startup_script.sh .
33
  RUN chmod +x fastapi_startup_script.sh
34
 
35
+ # Create logs directory and change ownership
36
  RUN mkdir -p /app/logs && \
37
+ chown -R appuser:appuser /app
 
38
 
39
+ # Set environment variables for Ollama
40
+ ENV OLLAMA_HOME=/home/appuser/.ollama
41
+ ENV HOME=/home/appuser
42
 
43
  # Switch to non-root user
44
  USER appuser
fastapi_startup_script.sh CHANGED
@@ -1,6 +1,14 @@
1
  #!/bin/bash
2
 
 
 
 
 
 
 
 
3
  # Start Ollama server in background
 
4
  ollama serve &
5
 
6
  # Wait for Ollama to start
 
1
  #!/bin/bash
2
 
3
+ # Debug: Check current user and permissions
4
+ echo "Current user: $(whoami)"
5
+ echo "Home directory: $HOME"
6
+ echo "Ollama home: $OLLAMA_HOME"
7
+ echo "Checking .ollama directory permissions:"
8
+ ls -la /home/appuser/.ollama/ || echo "Directory doesn't exist"
9
+
10
  # Start Ollama server in background
11
+ echo "Starting Ollama server..."
12
  ollama serve &
13
 
14
  # Wait for Ollama to start