brendon-ai commited on
Commit
5fcc1da
·
verified ·
1 Parent(s): ac3f3ed

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +55 -0
Dockerfile ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use Ubuntu as base image for better Ollama compatibility
2
+ FROM ubuntu:22.04
3
+
4
+ # Prevent interactive prompts during package installation
5
+ ENV DEBIAN_FRONTEND=noninteractive
6
+
7
+ # Set working directory
8
+ WORKDIR /app
9
+
10
+ # Install system dependencies
11
+ RUN apt-get update && apt-get install -y \
12
+ curl \
13
+ python3 \
14
+ python3-pip \
15
+ python3-venv \
16
+ wget \
17
+ ca-certificates \
18
+ sudo \
19
+ dos2unix \
20
+ && rm -rf /var/lib/apt/lists/*
21
+
22
+ # Create and activate virtual environment
23
+ RUN python3 -m venv /opt/venv
24
+ ENV PATH="/opt/venv/bin:$PATH"
25
+
26
+ # Install Python dependencies
27
+ COPY requirements.txt .
28
+ RUN pip install --no-cache-dir --upgrade pip && \
29
+ pip install --no-cache-dir -r requirements.txt
30
+
31
+ # Install Ollama
32
+ RUN curl -fsSL https://ollama.ai/install.sh | sh
33
+
34
+ # Copy application files
35
+ COPY app.py .
36
+ COPY startup.sh .
37
+
38
+ # Fix line endings and make startup script executable
39
+ RUN dos2unix startup.sh && chmod +x startup.sh
40
+
41
+ # Set environment variables for Ollama (using /tmp for guaranteed write access)
42
+ ENV HOME=/tmp
43
+ ENV OLLAMA_HOST=0.0.0.0:11434
44
+ ENV OLLAMA_MODELS=/tmp/ollama/models
45
+ ENV OLLAMA_HOME=/tmp/ollama
46
+
47
+ # Expose ports
48
+ EXPOSE 7860 11434
49
+
50
+ # Health check
51
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \
52
+ CMD curl -f http://localhost:7860/health || exit 1
53
+
54
+ # Start both Ollama server and FastAPI app
55
+ CMD ["/bin/bash", "./startup.sh"]