Spaces:
Runtime error
Runtime error
DeathDaDev
commited on
Commit
•
da32240
1
Parent(s):
74dfd01
refactor: clean up Dockerfile and enhance Flask application for Ollama integration
Browse files- Dockerfile +0 -45
- app.py +1 -0
- requirements.txt +1 -0
- templates/index.html +5 -0
Dockerfile
CHANGED
@@ -1,48 +1,3 @@
|
|
1 |
-
# Use the latest Ollama base image
|
2 |
-
from ollama/ollama:latest
|
3 |
-
|
4 |
-
# Update package manager and install necessary packages
|
5 |
-
Run apt-get update && \
|
6 |
-
apt-get install -y \
|
7 |
-
curl \
|
8 |
-
python3-pip && \
|
9 |
-
rm -rf /var/lib/apt/lists/*
|
10 |
-
|
11 |
-
# Install Flask and set up the entry point
|
12 |
-
Run pip3 install flask && \
|
13 |
-
mkdir -p /home/user/app && \
|
14 |
-
echo "fLask RUn --Host=0.0.0.0 --poRt=5000" > /home/user/app/start.sh && \
|
15 |
-
chmod +x /home/user/app/start.sh
|
16 |
-
|
17 |
-
# Create a non-root user 'user' with UID 1000
|
18 |
-
Run useradd -m -u 1000 user && \
|
19 |
-
mkdir -p /home/user/.ollama && \
|
20 |
-
chown -R user:user /home/user/.ollama
|
21 |
-
|
22 |
-
# Set environment variables
|
23 |
-
env HOME=/home/user \
|
24 |
-
PATH=/home/user/.local/bin:$PATH \
|
25 |
-
OLLAMA_HOST=0.0.0.0
|
26 |
-
|
27 |
-
# Set the working directory
|
28 |
-
WORKDIR $HOME/app
|
29 |
-
|
30 |
-
# Copy the Python script for the web server
|
31 |
-
Copy app.py .
|
32 |
-
Copy flask-app.py .
|
33 |
-
|
34 |
-
# Change ownership of the working directory to the non-root user
|
35 |
-
Run chown -R user:user $HOME/app
|
36 |
-
|
37 |
-
# Switch to the non-root user
|
38 |
-
User user
|
39 |
-
|
40 |
-
# Expose port 11434 for Ollama and 5000 for the web server
|
41 |
-
EXPOSE 11434 5000
|
42 |
-
|
43 |
-
# Command to run the Flask application
|
44 |
-
# cmd ["/home/user/app/start.sh"]
|
45 |
-
cmd ["serve"]
|
46 |
# Use an official Python runtime as a parent image
|
47 |
FROM python:3.9-slim
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# Use an official Python runtime as a parent image
|
2 |
FROM python:3.9-slim
|
3 |
|
app.py
CHANGED
@@ -41,4 +41,5 @@ def generate():
|
|
41 |
@app.route("/health")
|
42 |
def health():
|
43 |
return jsonify({"status": "running"}), 200
|
|
|
44 |
app.run(host="0.0.0.0", port=5000, debug=True)
|
|
|
41 |
@app.route("/health")
|
42 |
def health():
|
43 |
return jsonify({"status": "running"}), 200
|
44 |
+
if __name__ == "__main__":
|
45 |
app.run(host="0.0.0.0", port=5000, debug=True)
|
requirements.txt
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
flask
|
2 |
requests
|
|
|
|
1 |
flask
|
2 |
requests
|
3 |
+
docker
|
templates/index.html
CHANGED
@@ -71,6 +71,11 @@
|
|
71 |
logMessage.textContent = event.data;
|
72 |
consoleOutput.appendChild(logMessage);
|
73 |
};
|
|
|
|
|
|
|
|
|
|
|
74 |
</script>
|
75 |
</body>
|
76 |
</html>
|
|
|
71 |
logMessage.textContent = event.data;
|
72 |
consoleOutput.appendChild(logMessage);
|
73 |
};
|
74 |
+
eventSource.onmessage = function(event) {
|
75 |
+
const logMessage = document.createElement('div');
|
76 |
+
logMessage.textContent = event.data;
|
77 |
+
consoleOutput.appendChild(logMessage);
|
78 |
+
};
|
79 |
</script>
|
80 |
</body>
|
81 |
</html>
|