Spaces:
Running
Running
Commit ·
13a69d0
1
Parent(s): 90c0e10
Fix supervisord permissions for HF Spaces non-root user
Browse files- Dockerfile +14 -13
Dockerfile
CHANGED
|
@@ -32,9 +32,14 @@ COPY dashboard/ ./dashboard/
|
|
| 32 |
COPY data/ ./data/
|
| 33 |
COPY openenv.yaml ./
|
| 34 |
|
| 35 |
-
# Configure Supervisor
|
| 36 |
-
RUN echo "[
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
echo "nodaemon=true" >> /etc/supervisor/conf.d/supervisord.conf && \
|
|
|
|
| 38 |
echo "[program:go-env]" >> /etc/supervisor/conf.d/supervisord.conf && \
|
| 39 |
echo "command=/usr/local/bin/gridmind-server" >> /etc/supervisor/conf.d/supervisord.conf && \
|
| 40 |
echo "environment=PORT=7860" >> /etc/supervisor/conf.d/supervisord.conf && \
|
|
@@ -42,6 +47,7 @@ RUN echo "[supervisord]" > /etc/supervisor/conf.d/supervisord.conf && \
|
|
| 42 |
echo "stdout_logfile_maxbytes=0" >> /etc/supervisor/conf.d/supervisord.conf && \
|
| 43 |
echo "stderr_logfile=/dev/stderr" >> /etc/supervisor/conf.d/supervisord.conf && \
|
| 44 |
echo "stderr_logfile_maxbytes=0" >> /etc/supervisor/conf.d/supervisord.conf && \
|
|
|
|
| 45 |
echo "[program:dashboard]" >> /etc/supervisor/conf.d/supervisord.conf && \
|
| 46 |
echo "command=python -m uvicorn dashboard.server:app --host 0.0.0.0 --port 7861" >> /etc/supervisor/conf.d/supervisord.conf && \
|
| 47 |
echo "stdout_logfile=/dev/stdout" >> /etc/supervisor/conf.d/supervisord.conf && \
|
|
@@ -49,18 +55,13 @@ RUN echo "[supervisord]" > /etc/supervisor/conf.d/supervisord.conf && \
|
|
| 49 |
echo "stderr_logfile=/dev/stderr" >> /etc/supervisor/conf.d/supervisord.conf && \
|
| 50 |
echo "stderr_logfile_maxbytes=0" >> /etc/supervisor/conf.d/supervisord.conf
|
| 51 |
|
| 52 |
-
# Create run directory for supervisor
|
| 53 |
-
RUN mkdir -p /var/run/supervisor /var/log/supervisor && \
|
| 54 |
-
chmod 755 /var/run/supervisor /var/log/supervisor
|
| 55 |
-
|
| 56 |
-
# Add a non-root user (good practice and required for some HF Spaces configs)
|
| 57 |
-
RUN useradd -m -u 1000 user && \
|
| 58 |
-
chown -R user:user /app && \
|
| 59 |
-
chown -R user:user /var/run/supervisor /var/log/supervisor
|
| 60 |
-
|
| 61 |
# EXPOSE 7860 only - this is the main OpenEnv API endpoint (reverse proxy + /dashboard)
|
| 62 |
# Port 7861 (dashboard) runs internally only and is accessed via /dashboard proxy
|
| 63 |
EXPOSE 7860
|
| 64 |
|
| 65 |
-
#
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
COPY data/ ./data/
|
| 33 |
COPY openenv.yaml ./
|
| 34 |
|
| 35 |
+
# Configure Supervisor to use /tmp for socket and pid files (writable by any user)
|
| 36 |
+
RUN echo "[unix_http_server]" > /etc/supervisor/conf.d/supervisord.conf && \
|
| 37 |
+
echo "file=/tmp/supervisor.sock" >> /etc/supervisor/conf.d/supervisord.conf && \
|
| 38 |
+
echo "" >> /etc/supervisor/conf.d/supervisord.conf && \
|
| 39 |
+
echo "[supervisord]" >> /etc/supervisor/conf.d/supervisord.conf && \
|
| 40 |
+
echo "pidfile=/tmp/supervisord.pid" >> /etc/supervisor/conf.d/supervisord.conf && \
|
| 41 |
echo "nodaemon=true" >> /etc/supervisor/conf.d/supervisord.conf && \
|
| 42 |
+
echo "" >> /etc/supervisor/conf.d/supervisord.conf && \
|
| 43 |
echo "[program:go-env]" >> /etc/supervisor/conf.d/supervisord.conf && \
|
| 44 |
echo "command=/usr/local/bin/gridmind-server" >> /etc/supervisor/conf.d/supervisord.conf && \
|
| 45 |
echo "environment=PORT=7860" >> /etc/supervisor/conf.d/supervisord.conf && \
|
|
|
|
| 47 |
echo "stdout_logfile_maxbytes=0" >> /etc/supervisor/conf.d/supervisord.conf && \
|
| 48 |
echo "stderr_logfile=/dev/stderr" >> /etc/supervisor/conf.d/supervisord.conf && \
|
| 49 |
echo "stderr_logfile_maxbytes=0" >> /etc/supervisor/conf.d/supervisord.conf && \
|
| 50 |
+
echo "" >> /etc/supervisor/conf.d/supervisord.conf && \
|
| 51 |
echo "[program:dashboard]" >> /etc/supervisor/conf.d/supervisord.conf && \
|
| 52 |
echo "command=python -m uvicorn dashboard.server:app --host 0.0.0.0 --port 7861" >> /etc/supervisor/conf.d/supervisord.conf && \
|
| 53 |
echo "stdout_logfile=/dev/stdout" >> /etc/supervisor/conf.d/supervisord.conf && \
|
|
|
|
| 55 |
echo "stderr_logfile=/dev/stderr" >> /etc/supervisor/conf.d/supervisord.conf && \
|
| 56 |
echo "stderr_logfile_maxbytes=0" >> /etc/supervisor/conf.d/supervisord.conf
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
# EXPOSE 7860 only - this is the main OpenEnv API endpoint (reverse proxy + /dashboard)
|
| 59 |
# Port 7861 (dashboard) runs internally only and is accessed via /dashboard proxy
|
| 60 |
EXPOSE 7860
|
| 61 |
|
| 62 |
+
# Add a non-root user (good practice and required for some HF Spaces configs)
|
| 63 |
+
RUN useradd -m -u 1000 user && chown -R user:user /app
|
| 64 |
+
|
| 65 |
+
# Run supervisord to manage both Go server and Python dashboard
|
| 66 |
+
# Using /tmp for socket and pid files (writable by any user, including uid 1000)
|
| 67 |
+
CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|