Bahodir Nematjonov commited on
Commit
abc7cea
·
1 Parent(s): de06a50

docker changes

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -8
Dockerfile CHANGED
@@ -4,25 +4,38 @@ FROM python:3.9
4
  # Set the working directory to /code
5
  WORKDIR /code
6
 
7
- # Copy the current directory contents into the container at /code
8
- COPY ./requirements.txt /code/requirements.txt
 
 
 
 
 
 
9
 
10
- # Install requirements.txt
 
11
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
12
 
13
  # Set up a new user named "user" with user ID 1000
14
  RUN useradd -m -u 1000 user
 
15
  # Switch to the "user" user
16
  USER user
17
- # Set home to the user's home directory
 
18
  ENV HOME=/home/user \
19
- PATH=/home/user/.local/bin:$PATH
 
20
 
21
- # Set the working directory to the user's home directory
22
  WORKDIR $HOME/app
23
 
24
- # Copy the current directory contents into the container at $HOME/app setting the owner to the user
25
  COPY --chown=user . $HOME/app
26
 
27
- CMD ollama serve > /tmp/ollama.log 2>&1 & uvicorn main:app --host 0.0.0.0 --port 7860
 
28
 
 
 
 
4
  # Set the working directory to /code
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
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 home 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 and set ownership
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 before running FastAPI
41
+ CMD ollama serve > /tmp/ollama.log 2>&1 & sleep 5 && uvicorn main:app --host 0.0.0.0 --port 7860