Indrajit Ari commited on
Commit
6d4d91c
Β·
1 Parent(s): 7ec3321

fix: resolve nginx permission crash in restricted environment

Browse files
Files changed (2) hide show
  1. Dockerfile +7 -3
  2. nginx.conf +14 -2
Dockerfile CHANGED
@@ -60,11 +60,15 @@ COPY --from=frontend-builder /build/frontend/public ./frontend/public
60
  COPY nginx.conf /etc/nginx/nginx.conf
61
  COPY supervisord.conf /etc/supervisor/conf.d/app.conf
62
 
63
- # ── Directories & Permissions ────────────────────────────────────────────────
64
- # Ensure all runtime directories exist and are writable by any user (Hugging Face)
 
 
 
65
  RUN mkdir -p /tmp/video_seg/uploads /tmp/video_seg/outputs \
 
66
  && mkdir -p /var/log/supervisor /var/run /var/lib/nginx /var/log/nginx \
67
- && chmod -R 777 /tmp/video_seg \
68
  && chmod -R 777 /var/log/supervisor \
69
  && chmod -R 777 /var/lib/nginx \
70
  && chmod -R 777 /var/log/nginx \
 
60
  COPY nginx.conf /etc/nginx/nginx.conf
61
  COPY supervisord.conf /etc/supervisor/conf.d/app.conf
62
 
63
+ # ── Directories, Permissions & Cleanup ───────────────────────────────────────
64
+ # Remove default nginx config to prevent conflicts
65
+ RUN rm -f /etc/nginx/sites-enabled/default
66
+
67
+ # Ensure all runtime directories exist and are writable by any user
68
  RUN mkdir -p /tmp/video_seg/uploads /tmp/video_seg/outputs \
69
+ && mkdir -p /tmp/client_temp /tmp/proxy_temp /tmp/fastcgi_temp /tmp/uwsgi_temp /tmp/scgi_temp \
70
  && mkdir -p /var/log/supervisor /var/run /var/lib/nginx /var/log/nginx \
71
+ && chmod -R 777 /tmp \
72
  && chmod -R 777 /var/log/supervisor \
73
  && chmod -R 777 /var/lib/nginx \
74
  && chmod -R 777 /var/log/nginx \
nginx.conf CHANGED
@@ -1,14 +1,26 @@
1
  # Run nginx in a way compatible with non-root Docker environments
2
  # like Hugging Face Spaces.
3
- pid /tmp/nginx.pid;
4
- events { worker_processes 1; }
 
 
 
 
 
 
 
 
5
 
6
  http {
 
 
 
7
  include /etc/nginx/mime.types;
8
  default_type application/octet-stream;
9
  sendfile on;
10
 
11
  # Explicitly set paths for temporary files to /tmp
 
12
  client_body_temp_path /tmp/client_temp;
13
  proxy_temp_path /tmp/proxy_temp;
14
  fastcgi_temp_path /tmp/fastcgi_temp;
 
1
  # Run nginx in a way compatible with non-root Docker environments
2
  # like Hugging Face Spaces.
3
+
4
+ # Send logs to /tmp to avoid permission issues in /var/log/nginx
5
+ error_log /tmp/error.log;
6
+ pid /tmp/nginx.pid;
7
+
8
+ worker_processes 1;
9
+
10
+ events {
11
+ worker_connections 1024;
12
+ }
13
 
14
  http {
15
+ # Move access logs as well
16
+ access_log /tmp/access.log;
17
+
18
  include /etc/nginx/mime.types;
19
  default_type application/octet-stream;
20
  sendfile on;
21
 
22
  # Explicitly set paths for temporary files to /tmp
23
+ # This prevents crashes if /var/lib/nginx/... is not writable
24
  client_body_temp_path /tmp/client_temp;
25
  proxy_temp_path /tmp/proxy_temp;
26
  fastcgi_temp_path /tmp/fastcgi_temp;