bambadij commited on
Commit
3d6b505
·
1 Parent(s): 724e936
compose.yml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: "3"
2
+
3
+ services:
4
+ web:
5
+ build: fastapi
6
+ ports:
7
+ -7860:8000
8
+ volumes:
9
+ -./fastapi:/app
10
+ networks:
11
+ - local-ai
12
+ ollama:
13
+ build: ollama
14
+ ports:
15
+ -11434:11434
16
+ volumes:
17
+ -tutorial-vol:/ollama
18
+ networks:
19
+ -local-ai
20
+ entrypoint: ["usr/bin/bash","/pull-llama3.sh"]
21
+
22
+ networks:
23
+ local-ai:
24
+ driver: bridge
25
+
26
+ volumes:
27
+ tutorial-vol:
28
+ driver: local
Dockerfile → fastapi/Dockerfile RENAMED
@@ -1,35 +1,12 @@
1
  # Utilise une image de base Python
2
  FROM python:3.9-slim
3
 
4
- # Installe les dépendances nécessaires
5
- RUN apt-get update && \
6
- apt-get install -y \
7
- systemd \
8
- sudo \
9
- curl \
10
- gnupg \
11
- lsb-release
12
- # Ajoute le fichier de service systemd
13
- COPY ollama.service /etc/systemd/system/ollama.service
14
- # Installe Ollama et configure les permissions
15
- RUN curl -fsSL https://ollama.com/install.sh | sh
16
- # Active le service et démarre systemd
17
- RUN sudo systemctl enable ollama.service
18
- RUN sudo systemctl daemon-reload
19
- RUN sudo systemctl enable ollama
20
- RUN sudo ollama run llama3
21
- # Télécharge le modèle Llama3
22
- # Ajoute le chemin d'Ollama au PATH
23
- ENV PATH="/root/.ollama:${PATH}"
24
-
25
- # Télécharge le modèle Llama3
26
- RUN ollama pull llama3:latest
27
 
28
  # Définit le répertoire de travail
29
  WORKDIR /app
30
 
31
  # Copie les fichiers de l'application dans le conteneur
32
- COPY . /app/
33
 
34
  # Installe les dépendances Python
35
  RUN pip install --upgrade pip
 
1
  # Utilise une image de base Python
2
  FROM python:3.9-slim
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  # Définit le répertoire de travail
6
  WORKDIR /app
7
 
8
  # Copie les fichiers de l'application dans le conteneur
9
+ COPY .requirements.txt /app/requirements.txt
10
 
11
  # Installe les dépendances Python
12
  RUN pip install --upgrade pip
app.py → fastapi/app.py RENAMED
@@ -46,6 +46,7 @@ async def generate_text(request: RequestModel):
46
  model="llama3:latest",
47
  messages=[{"role": "user", "content": prompt_first + request.text}],
48
  )
 
49
  generated_text = ""
50
  for chunk in response:
51
  if chunk.choices[0].delta.content is not None:
 
46
  model="llama3:latest",
47
  messages=[{"role": "user", "content": prompt_first + request.text}],
48
  )
49
+
50
  generated_text = ""
51
  for chunk in response:
52
  if chunk.choices[0].delta.content is not None:
requirements.txt → fastapi/requirements.txt RENAMED
File without changes
ollama.service DELETED
@@ -1,10 +0,0 @@
1
- Description=Ollama Service
2
- After=network-online.target
3
- il me faut ajouter tout ca dans le dockerfile ya pas de commande qui permet de le gerer
4
- [Service]
5
- ExecStart=/usr/bin/ollama serve
6
- User=ollama
7
- Group=ollama
8
- Restart=always
9
- RestartSec=3
10
- Environment="OLLAMA_MODELS=~/.ollama/models/"
 
 
 
 
 
 
 
 
 
 
 
ollama/Dockerfile ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ FROM ollama/ollama
2
+
3
+ COPY ./pull-llama3.sh /pull-llama3.sh
ollama/pull-llama3.sh ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ./bin/ollama serve &
2
+
3
+ pif=$!
4
+
5
+ sleep 5
6
+
7
+ echo "Pulling llama3 model"
8
+
9
+ ollama pull llama3
10
+
11
+ wait $pid