ChandimaPrabath commited on
Commit
57c485f
·
verified ·
1 Parent(s): 9e0d721

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -15
Dockerfile CHANGED
@@ -1,35 +1,36 @@
1
  # Use the latest version of the ollama image
2
  FROM ollama/ollama:latest
3
 
4
- # Install curl (the user already exists)
5
- # The base image is Debian-based, so it's better to run as root for package installation
6
  USER root
 
 
7
  RUN apt-get update && \
8
  apt-get install -y curl && \
9
  apt-get clean && \
10
  rm -rf /var/lib/apt/lists/*
11
 
12
- # Set environment variables for the existing ollama user
13
- # The home directory for the 'ollama' user is typically /home/ollama
14
- ENV HOME=/home/ollama \
15
- PATH=/home/ollama/.local/bin:$PATH \
 
 
 
16
  OLLAMA_HOST=0.0.0.0 \
17
  OLLAMA_ORIGINS=*
18
 
19
  # Set the working directory
20
- WORKDIR $HOME/app
21
 
22
- # Copy your script and set the correct ownership
23
- COPY --chown=ollama:ollama entrypoint.sh $HOME/app/
24
 
25
  # Make the entrypoint script executable
26
- RUN chmod +x $HOME/app/entrypoint.sh
27
-
28
- # ADDED: Ensure the ollama user owns its home directory and all contents
29
- RUN chown -R ollama:ollama /home/ollama
30
 
31
- # Switch to the non-root user
32
- USER ollama
33
 
34
  # Expose the port for the Ollama server
35
  EXPOSE 11434
 
1
  # Use the latest version of the ollama image
2
  FROM ollama/ollama:latest
3
 
4
+ # Switch to root to perform admin tasks
 
5
  USER root
6
+
7
+ # Install curl
8
  RUN apt-get update && \
9
  apt-get install -y curl && \
10
  apt-get clean && \
11
  rm -rf /var/lib/apt/lists/*
12
 
13
+ # Create a dedicated directory for our app.
14
+ # The user that runs ollama is UID 1000. We will use that.
15
+ RUN mkdir -p /app
16
+
17
+ # Set environment variables
18
+ ENV HOME=/app \
19
+ PATH=/app/.local/bin:$PATH \
20
  OLLAMA_HOST=0.0.0.0 \
21
  OLLAMA_ORIGINS=*
22
 
23
  # Set the working directory
24
+ WORKDIR /app
25
 
26
+ # Copy the entrypoint script and set ownership using the UID and GID
27
+ COPY --chown=1000:1000 entrypoint.sh .
28
 
29
  # Make the entrypoint script executable
30
+ RUN chmod +x entrypoint.sh
 
 
 
31
 
32
+ # Switch to the non-root user by its UID
33
+ USER 1000
34
 
35
  # Expose the port for the Ollama server
36
  EXPOSE 11434