eli02 commited on
Commit
6511fd1
·
1 Parent(s): 35c6be3

fix: Update nginx configuration to use /dev/shm for temp paths and improve logging

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -13
Dockerfile CHANGED
@@ -20,34 +20,39 @@ FROM nginx:alpine
20
  COPY --from=build /app/build /usr/share/nginx/html
21
  COPY nginx.conf /etc/nginx/conf.d/default.conf
22
 
23
- # Create a proper nginx.conf with temp paths in the http context
24
- RUN mkdir -p /tmp/nginx && \
25
- { \
26
- echo 'user nginx;'; \
27
  echo 'worker_processes auto;'; \
28
- echo 'error_log /var/log/nginx/error.log notice;'; \
29
- echo 'pid /tmp/nginx.pid;'; \
30
  echo 'events {'; \
31
  echo ' worker_connections 1024;'; \
32
  echo '}'; \
33
  echo 'http {'; \
34
  echo ' include /etc/nginx/mime.types;'; \
35
  echo ' default_type application/octet-stream;'; \
36
- echo ' client_body_temp_path /tmp/nginx/client_temp;'; \
37
- echo ' proxy_temp_path /tmp/nginx/proxy_temp;'; \
38
- echo ' fastcgi_temp_path /tmp/nginx/fastcgi_temp;'; \
39
- echo ' uwsgi_temp_path /tmp/nginx/uwsgi_temp;'; \
40
- echo ' scgi_temp_path /tmp/nginx/scgi_temp;'; \
41
  echo ' log_format main "$remote_addr - $remote_user [$time_local] \"$request\" $status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\"";'; \
42
- echo ' access_log /var/log/nginx/access.log main;'; \
43
  echo ' sendfile on;'; \
44
  echo ' keepalive_timeout 65;'; \
45
  echo ' include /etc/nginx/conf.d/*.conf;'; \
46
  echo '}'; \
47
  } > /etc/nginx/nginx.conf
48
 
 
 
 
 
 
 
 
49
  # Expose port
50
  EXPOSE 3000
51
 
52
- # Start nginx without the problematic include
53
  CMD ["nginx", "-g", "daemon off;"]
 
20
  COPY --from=build /app/build /usr/share/nginx/html
21
  COPY nginx.conf /etc/nginx/conf.d/default.conf
22
 
23
+ # Create a proper nginx.conf using /dev/shm which is usually writable in containers
24
+ RUN { \
 
 
25
  echo 'worker_processes auto;'; \
26
+ echo 'error_log /dev/stderr warn;'; \
27
+ echo 'pid /dev/shm/nginx.pid;'; \
28
  echo 'events {'; \
29
  echo ' worker_connections 1024;'; \
30
  echo '}'; \
31
  echo 'http {'; \
32
  echo ' include /etc/nginx/mime.types;'; \
33
  echo ' default_type application/octet-stream;'; \
34
+ echo ' client_body_temp_path /dev/shm/client_temp;'; \
35
+ echo ' proxy_temp_path /dev/shm/proxy_temp;'; \
36
+ echo ' fastcgi_temp_path /dev/shm/fastcgi_temp;'; \
37
+ echo ' uwsgi_temp_path /dev/shm/uwsgi_temp;'; \
38
+ echo ' scgi_temp_path /dev/shm/scgi_temp;'; \
39
  echo ' log_format main "$remote_addr - $remote_user [$time_local] \"$request\" $status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\"";'; \
40
+ echo ' access_log /dev/stdout main;'; \
41
  echo ' sendfile on;'; \
42
  echo ' keepalive_timeout 65;'; \
43
  echo ' include /etc/nginx/conf.d/*.conf;'; \
44
  echo '}'; \
45
  } > /etc/nginx/nginx.conf
46
 
47
+ # Create necessary directories in /dev/shm for nginx temp files
48
+ RUN mkdir -p /dev/shm/client_temp \
49
+ /dev/shm/proxy_temp \
50
+ /dev/shm/fastcgi_temp \
51
+ /dev/shm/uwsgi_temp \
52
+ /dev/shm/scgi_temp
53
+
54
  # Expose port
55
  EXPOSE 3000
56
 
57
+ # Start nginx
58
  CMD ["nginx", "-g", "daemon off;"]