joe4ai commited on
Commit
9d6fd1a
·
verified ·
1 Parent(s): 5e9b732

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +44 -0
Dockerfile ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use the official Python 3.9 image
2
+ FROM python:3.9
3
+
4
+ # Set the working directory
5
+ WORKDIR /code
6
+
7
+ # Install system dependencies
8
+ RUN apt-get update && apt-get install -y \
9
+ curl \
10
+ git \
11
+ && rm -rf /var/lib/apt/lists/*
12
+
13
+ # Install Ollama
14
+ RUN curl -fsSL https://ollama.ai/install.sh | sh
15
+
16
+ # Copy requirements and install dependencies
17
+ COPY ./requirements.txt /code/requirements.txt
18
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
19
+
20
+ # Set up a new user named "user" with user ID 1000
21
+ RUN useradd -m -u 1000 user
22
+
23
+ # Switch to the "user" user
24
+ USER user
25
+
26
+ # Set environment variables
27
+ ENV HOME=/home/user \
28
+ PATH=/home/user/.local/bin:$PATH \
29
+ OLLAMA_HOME="/tmp/ollama_cache"
30
+
31
+ # Set working directory
32
+ WORKDIR $HOME/app
33
+
34
+ # Copy application files
35
+ COPY --chown=user . $HOME/app
36
+
37
+ # Ensure Ollama has a cache directory
38
+ RUN mkdir -p /tmp/ollama_cache
39
+
40
+ # Start Ollama in the background and pull the model
41
+ RUN ollama serve > /tmp/ollama.log 2>&1 & sleep 5 && ollama pull mistral
42
+
43
+ # Start Ollama and Gradio UI
44
+ CMD ollama serve > /tmp/ollama.log 2>&1 & sleep 5 && python app.py