dmartincy commited on
Commit
da9dd3b
·
1 Parent(s): 5341e74

Add DocAuthoring and Nginx

Browse files
Files changed (3) hide show
  1. Dockerfile +21 -1
  2. nginx.conf +1 -1
  3. start-services.sh +18 -3
Dockerfile CHANGED
@@ -14,14 +14,26 @@ RUN apt-get update && apt-get install -y \
14
  unzip \
15
  clang \
16
  cuda-toolkit \
 
17
  && rm -rf /var/lib/apt/lists/*
18
 
19
  # Create directories and set permissions
20
  RUN mkdir -p /tmp/llamafile && \
21
  mkdir -p $HOME/models && \
22
  mkdir -p $HOME/app && \
 
23
  mkdir -p $HOME/.llamafile && \
24
- chown -R user:user $HOME
 
 
 
 
 
 
 
 
 
 
25
 
26
  # Install llamafiler
27
  RUN cd /tmp/llamafile && \
@@ -31,6 +43,9 @@ RUN cd /tmp/llamafile && \
31
  chmod +x /usr/local/bin/llamafiler && \
32
  rm -rf /tmp/llamafile
33
 
 
 
 
34
  # Switch to non-root user
35
  USER user
36
  WORKDIR $HOME/app
@@ -39,6 +54,11 @@ WORKDIR $HOME/app
39
  RUN wget -q https://huggingface.co/bartowski/gemma-2-2b-it-GGUF/resolve/main/gemma-2-2b-it-Q8_0.gguf -O $HOME/models/gemma-2b.gguf && \
40
  wget -q https://huggingface.co/leliuga/all-MiniLM-L6-v2-GGUF/resolve/main/all-MiniLM-L6-v2.F16.gguf -O $HOME/models/embeddings.gguf
41
 
 
 
 
 
 
42
  # Copy start script
43
  COPY --chown=user:user start-services.sh $HOME/app/
44
  RUN chmod +x $HOME/app/start-services.sh
 
14
  unzip \
15
  clang \
16
  cuda-toolkit \
17
+ nginx \
18
  && rm -rf /var/lib/apt/lists/*
19
 
20
  # Create directories and set permissions
21
  RUN mkdir -p /tmp/llamafile && \
22
  mkdir -p $HOME/models && \
23
  mkdir -p $HOME/app && \
24
+ mkdir -p $HOME/app/docauth && \
25
  mkdir -p $HOME/.llamafile && \
26
+ mkdir -p /var/cache/nginx && \
27
+ mkdir -p /var/log/nginx && \
28
+ mkdir -p /var/lib/nginx && \
29
+ mkdir -p /run/nginx && \
30
+ touch /var/run/nginx.pid && \
31
+ chown -R user:user $HOME && \
32
+ chown -R user:user /var/cache/nginx && \
33
+ chown -R user:user /var/log/nginx && \
34
+ chown -R user:user /var/lib/nginx && \
35
+ chown -R user:user /var/run/nginx.pid && \
36
+ chown -R user:user /run/nginx
37
 
38
  # Install llamafiler
39
  RUN cd /tmp/llamafile && \
 
43
  chmod +x /usr/local/bin/llamafiler && \
44
  rm -rf /tmp/llamafile
45
 
46
+ # Copy nginx configuration
47
+ COPY nginx.conf /etc/nginx/nginx.conf
48
+
49
  # Switch to non-root user
50
  USER user
51
  WORKDIR $HOME/app
 
54
  RUN wget -q https://huggingface.co/bartowski/gemma-2-2b-it-GGUF/resolve/main/gemma-2-2b-it-Q8_0.gguf -O $HOME/models/gemma-2b.gguf && \
55
  wget -q https://huggingface.co/leliuga/all-MiniLM-L6-v2-GGUF/resolve/main/all-MiniLM-L6-v2.F16.gguf -O $HOME/models/embeddings.gguf
56
 
57
+ # Copy web files
58
+ COPY --chown=user:user index.html $HOME/app/docauth/
59
+ COPY --chown=user:user document-authoring.js $HOME/app/docauth/
60
+ COPY --chown=user:user Sample.docx $HOME/app/docauth/
61
+
62
  # Copy start script
63
  COPY --chown=user:user start-services.sh $HOME/app/
64
  RUN chmod +x $HOME/app/start-services.sh
nginx.conf CHANGED
@@ -8,7 +8,7 @@ http {
8
  listen 7861;
9
 
10
  location / {
11
- root /docauth;
12
  }
13
 
14
  location /healthcheck {
 
8
  listen 7861;
9
 
10
  location / {
11
+ root /home/user/app/docauth;
12
  }
13
 
14
  location /healthcheck {
start-services.sh CHANGED
@@ -10,9 +10,24 @@ nvidia-smi --query-gpu=compute_cap --format=csv,noheader || echo "Warning: Could
10
  # Create temporary directory for llamafiler
11
  mkdir -p /tmp/llamafiler
12
 
13
- # Start the model in server mode
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  echo "Starting chat model..."
15
- TMPDIR=/tmp/llamafiler /usr/local/bin/llamafiler --model $HOME/models/gemma-2b.gguf -ngl 2 --listen 0.0.0.0:7860 --verbose &
16
  GEMMA_PID=$!
17
 
18
  # Wait for the model to be ready with a timeout
@@ -21,7 +36,7 @@ TIMEOUT=600 # 10 minutes timeout
21
  START_TIME=$SECONDS
22
 
23
  wait_for_services() {
24
- curl -s --fail -X POST http://127.0.0.1:7860/v1/chat/completions \
25
  -H "Content-Type: application/json" \
26
  -d '{"model": "gemma-2b", "messages":[{"role":"user","content":"hi"}]}' >/dev/null 2>&1
27
  }
 
10
  # Create temporary directory for llamafiler
11
  mkdir -p /tmp/llamafiler
12
 
13
+ # Start nginx
14
+ echo "Starting nginx..."
15
+ /usr/sbin/nginx -c /etc/nginx/nginx.conf
16
+ if [ $? -ne 0 ]; then
17
+ echo "Failed to start nginx"
18
+ exit 1
19
+ fi
20
+
21
+ # Verify nginx is running
22
+ if ! ps aux | grep nginx | grep -v grep > /dev/null; then
23
+ echo "Nginx failed to start"
24
+ exit 1
25
+ fi
26
+ echo "Nginx started successfully"
27
+
28
+ # Start the model in server mode (now on port 8081)
29
  echo "Starting chat model..."
30
+ TMPDIR=/tmp/llamafiler /usr/local/bin/llamafiler --model $HOME/models/gemma-2b.gguf -ngl 2 --listen 0.0.0.0:8081 --verbose &
31
  GEMMA_PID=$!
32
 
33
  # Wait for the model to be ready with a timeout
 
36
  START_TIME=$SECONDS
37
 
38
  wait_for_services() {
39
+ curl -s --fail -X POST http://127.0.0.1:8081/v1/chat/completions \
40
  -H "Content-Type: application/json" \
41
  -d '{"model": "gemma-2b", "messages":[{"role":"user","content":"hi"}]}' >/dev/null 2>&1
42
  }