Al-Alcoba-Inciarte commited on
Commit
5d32fba
·
verified ·
1 Parent(s): 501bd4b

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +32 -15
Dockerfile CHANGED
@@ -1,23 +1,40 @@
1
- # Use the official Ollama image as the base
2
- FROM ollama/ollama:latest
3
 
4
- USER root
 
 
 
 
5
 
6
- # Install Python, pip, and any other dependencies you need
7
- RUN apt-get update && apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*
8
 
9
- RUN pip3 install --upgrade pip
10
- RUN pip3 install gradio langchain ollama langchain-ollama langchain-community langchain-google-community langchain-text-splitters pypdf
11
 
12
- # Overwrite the default entrypoint
13
- ENTRYPOINT []
 
14
 
15
- WORKDIR /app
16
- COPY . /app
17
 
18
- RUN mkdir -p /app/flagged && chmod -R 777 /app/flagged
 
19
 
20
- # Expose the port that Hugging Face Spaces expects
21
- EXPOSE 7860
 
22
 
23
- CMD ["python3", "app.py"]
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use a lightweight Python 3.11 image as the base.
2
+ FROM python:3.11-slim
3
 
4
+ # Update package lists, install curl, and run the Ollama installer script.
5
+ # This downloads and installs Ollama, then cleans up the package lists.
6
+ RUN apt-get update && apt-get install -y curl && \
7
+ curl -fsSL https://ollama.ai/install.sh | sh && \
8
+ apt-get clean && rm -rf /var/lib/apt/lists/*
9
 
10
+ # Create a non-root user (named "user" with UID 1000) for better security.
11
+ RUN useradd -m -u 1000 user
12
 
13
+ # Switch to the newly created user.
14
+ USER user
15
 
16
+ # Set environment variables:
17
+ ENV HOME=/home/user \
18
+ PATH="/home/user/.local/bin:$PATH"
19
 
20
+ # Create directories for your application and logs.
21
+ RUN mkdir -p $HOME/docker_ollama $HOME/logs
22
 
23
+ # Set the working directory to the application directory.
24
+ WORKDIR $HOME/docker_ollama
25
 
26
+ # Copy the requirements.txt file into the container and install Python dependencies.
27
+ COPY --chown=user requirements.txt .
28
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
29
 
30
+ # Copy the rest of your application code into the container.
31
+ COPY --chown=user . .
32
+
33
+ # Ensure the start script has executable permissions.
34
+ RUN chmod +x start.sh
35
+
36
+ # Expose the necessary ports:
37
+ EXPOSE 7860 11434
38
+
39
+ # Set the container's default command to run the start.sh script when the container launches.
40
+ CMD ["./start.sh"]