s-ish commited on
Commit
ae521f4
·
verified ·
1 Parent(s): 5f3f4b1

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +8 -6
Dockerfile CHANGED
@@ -1,11 +1,12 @@
1
  FROM ollama/ollama:latest
2
 
3
- # Install Python3 and pip
4
  RUN apt-get update && apt-get install -y \
5
  python3 \
6
  python3-pip \
7
  curl \
8
  bash \
 
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
  # Set working directory
@@ -14,14 +15,15 @@ WORKDIR /app
14
  # Copy requirements
15
  COPY requirements.txt .
16
 
17
- # Install Python dependencies (with --break-system-packages for Docker)
18
  RUN pip3 install --break-system-packages --no-cache-dir -r requirements.txt
19
 
20
  # Copy application
21
  COPY app.py .
22
 
23
- # Create startup script
24
- RUN echo '#!/bin/bash\nset -e\necho "Starting Ollama..."\nollama serve &\nOLLAMA_PID=$!\nsleep 5\necho "Pulling model..."\nollama pull mistral\necho "Starting FastAPI..."\npython3 app.py' > /app/start.sh && chmod +x /app/start.sh
 
25
 
26
  # Expose ports
27
  EXPOSE 7860 11434
@@ -30,5 +32,5 @@ EXPOSE 7860 11434
30
  ENV OLLAMA_HOST=0.0.0.0:11434
31
  ENV PORT=7860
32
 
33
- # Start using the script
34
- CMD ["/app/start.sh"]
 
1
  FROM ollama/ollama:latest
2
 
3
+ # Install Python3, pip, and bash
4
  RUN apt-get update && apt-get install -y \
5
  python3 \
6
  python3-pip \
7
  curl \
8
  bash \
9
+ supervisor \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
  # Set working directory
 
15
  # Copy requirements
16
  COPY requirements.txt .
17
 
18
+ # Install Python dependencies
19
  RUN pip3 install --break-system-packages --no-cache-dir -r requirements.txt
20
 
21
  # Copy application
22
  COPY app.py .
23
 
24
+ # Create supervisor config to manage both services
25
+ RUN mkdir -p /etc/supervisor/conf.d && \
26
+ echo '[supervisord]\nnodaemon=true\n\n[program:ollama]\ncommand=/bin/ollama serve\nstartsecs=10\nautorestart=true\nstdout_logfile=/dev/stdout\nstdout_logfile_maxbytes=0\n\n[program:fastapi]\ncommand=/usr/bin/python3 /app/app.py\nstartsecs=5\nautorestart=true\nstdout_logfile=/dev/stdout\nstdout_logfile_maxbytes=0' > /etc/supervisor/conf.d/services.conf
27
 
28
  # Expose ports
29
  EXPOSE 7860 11434
 
32
  ENV OLLAMA_HOST=0.0.0.0:11434
33
  ENV PORT=7860
34
 
35
+ # Start supervisor (manages both ollama and fastapi)
36
+ CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]