NitinBot002 commited on
Commit
a077973
·
verified ·
1 Parent(s): 6eb0f28

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -15
Dockerfile CHANGED
@@ -3,23 +3,23 @@ FROM ollama/ollama:latest
3
  # Stay as root to make changes
4
  USER root
5
 
6
- # Create ollama user with a consistent UID and ensure proper ownership
7
- RUN if id -u ollama >/dev/null 2>&1; then \
8
- echo "ollama user already exists"; \
9
- else \
10
- if id -u 1000 >/dev/null 2>&1; then \
11
- echo "UID 1000 already exists. Using UID 1001..."; \
12
- useradd -m -u 1001 -s /bin/bash ollama; \
13
- else \
14
- useradd -m -u 1000 -s /bin/bash ollama; \
15
- fi \
16
- fi
17
-
18
- # Create necessary directories and set proper ownership
19
  RUN mkdir -p /home/ollama/.ollama/models && \
20
  mkdir -p /home/ollama/.ollama/logs && \
 
21
  chown -R ollama:ollama /home/ollama && \
22
- chmod -R 755 /home/ollama
 
 
 
 
23
 
24
  # Set environment variables
25
  ENV OLLAMA_HOST=0.0.0.0:7860 \
@@ -29,12 +29,18 @@ ENV OLLAMA_HOST=0.0.0.0:7860 \
29
  OLLAMA_CONTEXT_LENGTH=8196 \
30
  OLLAMA_KEEP_ALIVE=1m \
31
  OLLAMA_CPU_THREADS=4 \
32
- HOME=/home/ollama
 
33
 
34
  # Switch to ollama user
35
  USER ollama
36
  WORKDIR /home/ollama
37
 
 
 
 
 
 
38
  # Expose port
39
  EXPOSE 7860
40
 
 
3
  # Stay as root to make changes
4
  USER root
5
 
6
+ # Remove any existing ollama user and recreate with proper setup
7
+ RUN userdel -r ollama 2>/dev/null || true
8
+
9
+ # Create ollama user with home directory
10
+ RUN useradd -m -u 1000 -s /bin/bash ollama || \
11
+ useradd -m -u 1001 -s /bin/bash ollama
12
+
13
+ # Create necessary directories with proper permissions
 
 
 
 
 
14
  RUN mkdir -p /home/ollama/.ollama/models && \
15
  mkdir -p /home/ollama/.ollama/logs && \
16
+ touch /home/ollama/.ollama/.keep && \
17
  chown -R ollama:ollama /home/ollama && \
18
+ chmod -R 755 /home/ollama && \
19
+ chmod -R 775 /home/ollama/.ollama
20
+
21
+ # Ensure the ollama binary has proper permissions
22
+ RUN chmod +x /bin/ollama
23
 
24
  # Set environment variables
25
  ENV OLLAMA_HOST=0.0.0.0:7860 \
 
29
  OLLAMA_CONTEXT_LENGTH=8196 \
30
  OLLAMA_KEEP_ALIVE=1m \
31
  OLLAMA_CPU_THREADS=4 \
32
+ HOME=/home/ollama \
33
+ USER=ollama
34
 
35
  # Switch to ollama user
36
  USER ollama
37
  WORKDIR /home/ollama
38
 
39
+ # Verify permissions (this will help with debugging)
40
+ RUN ls -la /home/ollama/.ollama && \
41
+ touch /home/ollama/.ollama/test_write && \
42
+ rm /home/ollama/.ollama/test_write
43
+
44
  # Expose port
45
  EXPOSE 7860
46