Spaces:
Runtime error
Runtime error
da03
commited on
Commit
Β·
ba65ca0
1
Parent(s):
1828ec1
- Dockerfile +14 -11
Dockerfile
CHANGED
|
@@ -47,6 +47,9 @@ RUN echo 'server {' > /etc/nginx/sites-available/default && \
|
|
| 47 |
echo ' }' >> /etc/nginx/sites-available/default && \
|
| 48 |
echo '}' >> /etc/nginx/sites-available/default
|
| 49 |
|
|
|
|
|
|
|
|
|
|
| 50 |
# Give user sudo permissions for nginx
|
| 51 |
RUN echo "user ALL=(ALL) NOPASSWD: /usr/sbin/nginx, /usr/sbin/nginx -t, /usr/sbin/nginx -s quit" >> /etc/sudoers
|
| 52 |
|
|
@@ -81,13 +84,14 @@ RUN echo '#!/bin/bash' > /start_hf_spaces.sh && \
|
|
| 81 |
echo '' >> /start_hf_spaces.sh && \
|
| 82 |
echo '# Start nginx as root' >> /start_hf_spaces.sh && \
|
| 83 |
echo 'echo "π Starting nginx proxy..."' >> /start_hf_spaces.sh && \
|
|
|
|
| 84 |
echo 'nginx -t && nginx' >> /start_hf_spaces.sh && \
|
| 85 |
echo '' >> /start_hf_spaces.sh && \
|
| 86 |
-
echo '# Start dispatcher as user' >> /start_hf_spaces.sh && \
|
| 87 |
echo 'echo "π― Starting dispatcher..."' >> /start_hf_spaces.sh && \
|
| 88 |
-
echo '
|
| 89 |
-
echo '
|
| 90 |
-
echo 'DISPATCHER_PID
|
| 91 |
echo 'echo "π Dispatcher PID: $DISPATCHER_PID"' >> /start_hf_spaces.sh && \
|
| 92 |
echo '' >> /start_hf_spaces.sh && \
|
| 93 |
echo '# Wait for dispatcher to start' >> /start_hf_spaces.sh && \
|
|
@@ -103,11 +107,10 @@ RUN echo '#!/bin/bash' > /start_hf_spaces.sh && \
|
|
| 103 |
echo ' echo "β οΈ Nginx proxy test failed"' >> /start_hf_spaces.sh && \
|
| 104 |
echo 'fi' >> /start_hf_spaces.sh && \
|
| 105 |
echo '' >> /start_hf_spaces.sh && \
|
| 106 |
-
echo '# Start worker as user' >> /start_hf_spaces.sh && \
|
| 107 |
echo 'echo "π§ Starting worker..."' >> /start_hf_spaces.sh && \
|
| 108 |
-
echo '
|
| 109 |
-
echo '
|
| 110 |
-
echo 'WORKER_PID=$(pgrep -f "worker.py")' >> /start_hf_spaces.sh && \
|
| 111 |
echo 'echo "π Worker PID: $WORKER_PID"' >> /start_hf_spaces.sh && \
|
| 112 |
echo '' >> /start_hf_spaces.sh && \
|
| 113 |
echo '# Wait for worker to initialize' >> /start_hf_spaces.sh && \
|
|
@@ -118,9 +121,9 @@ RUN echo '#!/bin/bash' > /start_hf_spaces.sh && \
|
|
| 118 |
echo 'if ! kill -0 $WORKER_PID 2>/dev/null; then' >> /start_hf_spaces.sh && \
|
| 119 |
echo ' echo "β Worker failed to start"' >> /start_hf_spaces.sh && \
|
| 120 |
echo ' echo "π Worker log:"' >> /start_hf_spaces.sh && \
|
| 121 |
-
echo ' tail -n 50
|
| 122 |
echo ' echo "π Dispatcher log:"' >> /start_hf_spaces.sh && \
|
| 123 |
-
echo ' tail -n 50
|
| 124 |
echo ' exit 1' >> /start_hf_spaces.sh && \
|
| 125 |
echo 'fi' >> /start_hf_spaces.sh && \
|
| 126 |
echo '' >> /start_hf_spaces.sh && \
|
|
@@ -142,7 +145,7 @@ RUN echo '#!/bin/bash' > /start_hf_spaces.sh && \
|
|
| 142 |
echo '' >> /start_hf_spaces.sh && \
|
| 143 |
echo '# Keep the script running' >> /start_hf_spaces.sh && \
|
| 144 |
echo 'echo "π Following logs (Ctrl+C to stop):"' >> /start_hf_spaces.sh && \
|
| 145 |
-
echo 'tail -f
|
| 146 |
echo 'TAIL_PID=$!' >> /start_hf_spaces.sh && \
|
| 147 |
echo 'wait $DISPATCHER_PID' >> /start_hf_spaces.sh && \
|
| 148 |
echo 'kill $TAIL_PID 2>/dev/null || true' >> /start_hf_spaces.sh && \
|
|
|
|
| 47 |
echo ' }' >> /etc/nginx/sites-available/default && \
|
| 48 |
echo '}' >> /etc/nginx/sites-available/default
|
| 49 |
|
| 50 |
+
# Create directories for nginx
|
| 51 |
+
RUN mkdir -p /run/nginx && chmod 755 /run/nginx
|
| 52 |
+
|
| 53 |
# Give user sudo permissions for nginx
|
| 54 |
RUN echo "user ALL=(ALL) NOPASSWD: /usr/sbin/nginx, /usr/sbin/nginx -t, /usr/sbin/nginx -s quit" >> /etc/sudoers
|
| 55 |
|
|
|
|
| 84 |
echo '' >> /start_hf_spaces.sh && \
|
| 85 |
echo '# Start nginx as root' >> /start_hf_spaces.sh && \
|
| 86 |
echo 'echo "π Starting nginx proxy..."' >> /start_hf_spaces.sh && \
|
| 87 |
+
echo 'mkdir -p /run/nginx' >> /start_hf_spaces.sh && \
|
| 88 |
echo 'nginx -t && nginx' >> /start_hf_spaces.sh && \
|
| 89 |
echo '' >> /start_hf_spaces.sh && \
|
| 90 |
+
echo '# Start dispatcher as user using runuser' >> /start_hf_spaces.sh && \
|
| 91 |
echo 'echo "π― Starting dispatcher..."' >> /start_hf_spaces.sh && \
|
| 92 |
+
echo 'cd /home/user/app' >> /start_hf_spaces.sh && \
|
| 93 |
+
echo 'runuser -l user -c "cd /home/user/app && python dispatcher.py --port 8080" > dispatcher.log 2>&1 &' >> /start_hf_spaces.sh && \
|
| 94 |
+
echo 'DISPATCHER_PID=$!' >> /start_hf_spaces.sh && \
|
| 95 |
echo 'echo "π Dispatcher PID: $DISPATCHER_PID"' >> /start_hf_spaces.sh && \
|
| 96 |
echo '' >> /start_hf_spaces.sh && \
|
| 97 |
echo '# Wait for dispatcher to start' >> /start_hf_spaces.sh && \
|
|
|
|
| 107 |
echo ' echo "β οΈ Nginx proxy test failed"' >> /start_hf_spaces.sh && \
|
| 108 |
echo 'fi' >> /start_hf_spaces.sh && \
|
| 109 |
echo '' >> /start_hf_spaces.sh && \
|
| 110 |
+
echo '# Start worker as user using runuser' >> /start_hf_spaces.sh && \
|
| 111 |
echo 'echo "π§ Starting worker..."' >> /start_hf_spaces.sh && \
|
| 112 |
+
echo 'runuser -l user -c "cd /home/user/app && python worker.py --worker-address localhost:8001 --dispatcher-url http://localhost:8080" > worker.log 2>&1 &' >> /start_hf_spaces.sh && \
|
| 113 |
+
echo 'WORKER_PID=$!' >> /start_hf_spaces.sh && \
|
|
|
|
| 114 |
echo 'echo "π Worker PID: $WORKER_PID"' >> /start_hf_spaces.sh && \
|
| 115 |
echo '' >> /start_hf_spaces.sh && \
|
| 116 |
echo '# Wait for worker to initialize' >> /start_hf_spaces.sh && \
|
|
|
|
| 121 |
echo 'if ! kill -0 $WORKER_PID 2>/dev/null; then' >> /start_hf_spaces.sh && \
|
| 122 |
echo ' echo "β Worker failed to start"' >> /start_hf_spaces.sh && \
|
| 123 |
echo ' echo "π Worker log:"' >> /start_hf_spaces.sh && \
|
| 124 |
+
echo ' tail -n 50 worker.log' >> /start_hf_spaces.sh && \
|
| 125 |
echo ' echo "π Dispatcher log:"' >> /start_hf_spaces.sh && \
|
| 126 |
+
echo ' tail -n 50 dispatcher.log' >> /start_hf_spaces.sh && \
|
| 127 |
echo ' exit 1' >> /start_hf_spaces.sh && \
|
| 128 |
echo 'fi' >> /start_hf_spaces.sh && \
|
| 129 |
echo '' >> /start_hf_spaces.sh && \
|
|
|
|
| 145 |
echo '' >> /start_hf_spaces.sh && \
|
| 146 |
echo '# Keep the script running' >> /start_hf_spaces.sh && \
|
| 147 |
echo 'echo "π Following logs (Ctrl+C to stop):"' >> /start_hf_spaces.sh && \
|
| 148 |
+
echo 'tail -f dispatcher.log worker.log &' >> /start_hf_spaces.sh && \
|
| 149 |
echo 'TAIL_PID=$!' >> /start_hf_spaces.sh && \
|
| 150 |
echo 'wait $DISPATCHER_PID' >> /start_hf_spaces.sh && \
|
| 151 |
echo 'kill $TAIL_PID 2>/dev/null || true' >> /start_hf_spaces.sh && \
|