Spaces:
Paused
Paused
Arshit Malik commited on
Commit ·
09aa179
1
Parent(s): 14afb17
fix: move ollama install to start.sh for faster build, prevent Space pause during build
Browse files- Dockerfile +0 -2
- start.sh +17 -31
Dockerfile
CHANGED
|
@@ -6,8 +6,6 @@ RUN apt-get update && apt-get install -y \
|
|
| 6 |
python3 python3-pip ffmpeg curl git nginx zstd \
|
| 7 |
&& rm -rf /var/lib/apt/lists/*
|
| 8 |
|
| 9 |
-
RUN curl -fsSL https://ollama.com/install.sh | sh
|
| 10 |
-
|
| 11 |
RUN pip3 install --break-system-packages \
|
| 12 |
requests kaggle huggingface_hub \
|
| 13 |
google-api-python-client google-auth \
|
|
|
|
| 6 |
python3 python3-pip ffmpeg curl git nginx zstd \
|
| 7 |
&& rm -rf /var/lib/apt/lists/*
|
| 8 |
|
|
|
|
|
|
|
| 9 |
RUN pip3 install --break-system-packages \
|
| 10 |
requests kaggle huggingface_hub \
|
| 11 |
google-api-python-client google-auth \
|
start.sh
CHANGED
|
@@ -30,41 +30,31 @@ except Exception as e:
|
|
| 30 |
echo "[boot] Starting nginx..."
|
| 31 |
nginx
|
| 32 |
|
| 33 |
-
echo "[boot] Starting Ollama..."
|
| 34 |
-
OLLAMA_HOST=127.0.0.1 ollama serve &
|
| 35 |
-
|
| 36 |
echo "[boot] Starting status server on port 8080..."
|
| 37 |
python3 -c "
|
| 38 |
-
import http.server,
|
| 39 |
-
|
| 40 |
-
class Handler(http.server.BaseHTTPRequestHandler):
|
| 41 |
def do_GET(self):
|
| 42 |
-
try:
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
log = 'No log yet.'
|
| 46 |
-
body = f'''<!DOCTYPE html><html><head><meta charset=utf-8>
|
| 47 |
-
<meta http-equiv=refresh content=30>
|
| 48 |
-
<title>YT Pipeline</title>
|
| 49 |
-
<style>body{{font-family:monospace;background:#111;color:#0f0;padding:20px}}
|
| 50 |
-
pre{{background:#000;padding:10px;overflow-x:auto;white-space:pre-wrap}}</style>
|
| 51 |
-
</head><body>
|
| 52 |
-
<h2>YouTube Shorts Pipeline</h2>
|
| 53 |
-
<p>Space is running. Pipeline log (last 3000 chars, auto-refreshes every 30s):</p>
|
| 54 |
-
<pre>{log}</pre>
|
| 55 |
-
</body></html>'''.encode()
|
| 56 |
self.send_response(200)
|
| 57 |
self.send_header('Content-Type','text/html')
|
| 58 |
-
self.send_header('Content-Length',str(len(
|
| 59 |
self.end_headers()
|
| 60 |
-
self.wfile.write(
|
| 61 |
-
def log_message(self,
|
| 62 |
-
|
| 63 |
-
httpd = http.server.HTTPServer(('0.0.0.0', 8080), Handler)
|
| 64 |
-
print('[status] Server running on port 8080')
|
| 65 |
-
httpd.serve_forever()
|
| 66 |
" &
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
echo "[boot] Waiting for Ollama..."
|
| 69 |
for i in $(seq 1 60); do
|
| 70 |
if curl -sf http://127.0.0.1:11434/api/tags > /dev/null 2>&1; then
|
|
@@ -80,8 +70,4 @@ echo "[boot] Starting pipeline..."
|
|
| 80 |
python3 /app/automation.py >> /app/pipeline.log 2>&1 &
|
| 81 |
echo "[boot] Pipeline PID: $!"
|
| 82 |
|
| 83 |
-
echo "[boot] Trying OpenClaw (optional)..."
|
| 84 |
-
export OLLAMA_HOST=http://127.0.0.1:11434
|
| 85 |
-
openclaw gateway start || echo "[boot] OpenClaw unavailable, status server is active"
|
| 86 |
-
|
| 87 |
sleep infinity
|
|
|
|
| 30 |
echo "[boot] Starting nginx..."
|
| 31 |
nginx
|
| 32 |
|
|
|
|
|
|
|
|
|
|
| 33 |
echo "[boot] Starting status server on port 8080..."
|
| 34 |
python3 -c "
|
| 35 |
+
import http.server, os, time
|
| 36 |
+
class H(http.server.BaseHTTPRequestHandler):
|
|
|
|
| 37 |
def do_GET(self):
|
| 38 |
+
try: log = open('/app/pipeline.log').read()[-3000:]
|
| 39 |
+
except: log = 'No log yet.'
|
| 40 |
+
b = f'<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=refresh content=30><title>YT Pipeline</title><style>body{{font-family:monospace;background:#111;color:#0f0;padding:20px}}pre{{background:#000;padding:10px;white-space:pre-wrap}}</style></head><body><h2>YouTube Shorts Pipeline</h2><p>Space is running. Pipeline log (last 3000 chars, auto-refreshes every 30s):</p><pre>{log}</pre></body></html>'.encode()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
self.send_response(200)
|
| 42 |
self.send_header('Content-Type','text/html')
|
| 43 |
+
self.send_header('Content-Length',str(len(b)))
|
| 44 |
self.end_headers()
|
| 45 |
+
self.wfile.write(b)
|
| 46 |
+
def log_message(self,*a): pass
|
| 47 |
+
http.server.HTTPServer(('0.0.0.0',8080),H).serve_forever()
|
|
|
|
|
|
|
|
|
|
| 48 |
" &
|
| 49 |
|
| 50 |
+
echo "[boot] Installing Ollama (first boot only)..."
|
| 51 |
+
if ! command -v ollama &>/dev/null; then
|
| 52 |
+
curl -fsSL https://ollama.com/install.sh | sh
|
| 53 |
+
fi
|
| 54 |
+
|
| 55 |
+
echo "[boot] Starting Ollama..."
|
| 56 |
+
OLLAMA_HOST=127.0.0.1 ollama serve &
|
| 57 |
+
|
| 58 |
echo "[boot] Waiting for Ollama..."
|
| 59 |
for i in $(seq 1 60); do
|
| 60 |
if curl -sf http://127.0.0.1:11434/api/tags > /dev/null 2>&1; then
|
|
|
|
| 70 |
python3 /app/automation.py >> /app/pipeline.log 2>&1 &
|
| 71 |
echo "[boot] Pipeline PID: $!"
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
sleep infinity
|