File size: 1,157 Bytes
5b6bc41
ceace01
0151794
ae00b8b
ceace01
5b6bc41
ae00b8b
5b6bc41
 
ae00b8b
f780aa2
ceace01
e3f7c3a
ceace01
f780aa2
0151794
3f09d3b
eaaf4b4
 
 
0151794
3f09d3b
ceace01
3f09d3b
 
0151794
3f09d3b
 
0151794
ae00b8b
ceace01
 
0151794
ae00b8b
ceace01
ae00b8b
 
eaaf4b4
0151794
3f09d3b
 
ae00b8b
3ccfba8
94252e7
eaaf4b4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Use the latest Ollama base image
from ollama/ollama:latest

# Update package manager and install necessary packages
Run apt-get update && \
    apt-get install -y \
    curl \
    python3-pip && \
    rm -rf /var/lib/apt/lists/*

# Install Flask and set up the entry point
Run pip3 install flask && \
    mkdir -p /home/user/app && \
    echo "fLask RUn --Host=0.0.0.0 --poRt=5000" > /home/user/app/start.sh && \
    chmod +x /home/user/app/start.sh

# Create a non-root user 'user' with UID 1000
Run useradd -m -u 1000 user && \
    mkdir -p /home/user/.ollama && \
    chown -R user:user /home/user/.ollama

# Set environment variables
env HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH \
    OLLAMA_HOST=0.0.0.0

# Set the working directory
WORKDIR $HOME/app

# Copy the Python script for the web server
Copy app.py .
Copy flask-app.py .

# Change ownership of the working directory to the non-root user
Run chown -R user:user $HOME/app

# Switch to the non-root user
User user

# Expose port 11434 for Ollama and 5000 for the web server
EXPOSE 11434 5000

# Command to run the Flask application
# cmd ["/home/user/app/start.sh"]
cmd ["serve"]