Move files in a sub forlder dedicated to chat-ai.

This commit is contained in:
Florian THIERRY
2026-06-11 11:50:26 +02:00
parent 97114a4380
commit e4de011b63
4 changed files with 2 additions and 2 deletions
+71
View File
@@ -0,0 +1,71 @@
# Étape 1 : build de llama.cpp
FROM ubuntu:24.04 AS builder
LABEL maintainer="vous" \
description="llama.cpp + Mistral-7B-Instruct (inférence locale isolée)"
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
lsb-release \
gnupg \
ca-certificates \
build-essential \
cmake \
git \
libopenblas-dev \
pkg-config \
libvulkan-dev \
vulkan-tools \
wget
# Télécharge et installe le Vulkan SDK
RUN wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | apt-key add - && \
echo "deb https://packages.lunarg.com/vulkan/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/lunarg-vulkan.list && \
apt-get update && \
apt-get install -y vulkan-sdk && \
rm -rf /var/lib/apt/lists/*
WORKDIR /build
RUN git clone --depth 1 https://github.com/ggerganov/llama.cpp .
RUN cmake -B build \
-DLLAMA_BUILD_TESTS=OFF \
-DLLAMA_BUILD_EXAMPLES=ON \
-DGGML_BLAS=ON \
-DGGML_BLAS_VENDOR=OpenBLAS \
-DCMAKE_INSTALL_PREFIX=/install \
-DGGML_VULKAN=ON \
-DVulkan_GLSLC_EXECUTABLE=/usr/bin/glslc \
&& cmake --build build --config Release -j$(nproc) \
&& cmake --install build --prefix /install
# Étape 2 : image finale (runtime minimal)
FROM ubuntu:24.04 AS runtime
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
libopenblas0-openmp \
libgomp1 \
libvulkan1 \
mesa-vulkan-drivers \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /install/ /usr/local/
RUN ldconfig
RUN useradd -m -u 1001 -s /bin/bash llama
USER llama
WORKDIR /home/llama
RUN mkdir -p /home/llama/models
EXPOSE 8080
CMD ["llama-server", \
"--model", "/home/llama/models/mistral-7b-instruct.gguf", \
"--host", "0.0.0.0", \
"--port", "8080", \
"-c", "4096", \
"-ngl", "33"]
+50
View File
@@ -0,0 +1,50 @@
name: mistral-local
services:
local-ai:
build:
context: .
dockerfile: Dockerfile
image: local-ai
container_name: local-ai
networks:
- mistral-net
ports:
- "127.0.0.1:8080:8080"
# Limites de ressources
deploy:
resources:
limits:
memory: 12g
cpus: "8"
# Sécurité
read_only: true
security_opt:
- no-new-privileges:true
tmpfs:
- /tmp:size=256m
devices:
- /dev/dri:/dev/dri
group_add:
- video
environment:
- GGML_VK_VISIBLE_DEVICES=0
volumes:
- ../ai-models/mistral-7b-instruct.gguf:/home/llama/models/mistral-7b-instruct.gguf:ro
- ../workspace:/home/llama/workspace
# Health check — vérifie que le serveur répond
# healthcheck:
# test: ["CMD-SHELL", "curl -sf http://localhost:8080/health || exit 1"]
# interval: 30s
# timeout: 10s
# retries: 3
# start_period: 60s # laisser le temps au modèle de charger
networks:
mistral-net:
name: mistral-net
driver: bridge
internal: false # pas de passerelle vers Internet
driver_opts:
com.docker.network.bridge.name: br-mistral
+35
View File
@@ -0,0 +1,35 @@
#!/bin/bash
action=$1
args=$2
build_image() {
docker build $args -t local-ai .
}
start_container() {
# Premier démarrage (build + lancement)
docker compose up --build
# Voir les logs en temps réel
docker compose logs -f
# Arrêter
docker compose down
# Vérifier l'état du health check
docker compose ps
}
main() {
if [[ $action = 'build' ]] then
build_image
elif [[ $action = 'all' ]] then
build_image
start_container
else
start_container
fi
}
main
+4
View File
@@ -0,0 +1,4 @@
torch==2.2.0 --index-url https://download.pytorch.org/whl/cpu
transformers==4.40.0
accelerate==0.27.0
sentencepiece