Raymond Weitekamp commited on
Commit
7eb3a7a
·
1 Parent(s): f4101fd

Fix Nginx configuration and test script

Browse files
Files changed (1) hide show
  1. Dockerfile +40 -3
Dockerfile CHANGED
@@ -46,7 +46,43 @@ RUN mkdir -p /var/lib/nginx/body && \
46
  chmod 755 /var/lib/nginx && \
47
  chmod -R 755 /var/lib/nginx/* && \
48
  chmod -R 755 /var/log/nginx && \
49
- chmod -R 755 /run/nginx
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  # Create a test script for build-time verification
52
  RUN echo '#!/bin/bash\n\
@@ -59,7 +95,8 @@ python3 -m http.server 3939 &\n\
59
  VIEWER_PID=$!\n\
60
  \n\
61
  echo "Starting nginx..."\n\
62
- nginx\n\
 
63
  \n\
64
  echo "Waiting for servers to start..."\n\
65
  sleep 2\n\
@@ -72,7 +109,7 @@ echo "Testing viewer proxy..."\n\
72
  VIEWER_STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:7860/proxy/3939/viewer)\n\
73
  echo "Viewer status: $VIEWER_STATUS"\n\
74
  \n\
75
- nginx -s stop\n\
76
  kill $SERVER_PID $VIEWER_PID\n\
77
  \n\
78
  if [ "$MAIN_STATUS" = "200" ] && [ "$VIEWER_STATUS" = "200" ]; then\n\
 
46
  chmod 755 /var/lib/nginx && \
47
  chmod -R 755 /var/lib/nginx/* && \
48
  chmod -R 755 /var/log/nginx && \
49
+ chmod -R 755 /run/nginx && \
50
+ rm -f /etc/nginx/sites-enabled/default
51
+
52
+ # Create test nginx configuration
53
+ RUN echo 'worker_processes 1;\n\
54
+ error_log stderr info;\n\
55
+ pid /run/nginx/nginx.pid;\n\
56
+ events {\n\
57
+ worker_connections 1024;\n\
58
+ }\n\
59
+ http {\n\
60
+ access_log /dev/stdout;\n\
61
+ upstream nicegui {\n\
62
+ server 127.0.0.1:7861;\n\
63
+ }\n\
64
+ upstream viewer {\n\
65
+ server 127.0.0.1:3939;\n\
66
+ }\n\
67
+ server {\n\
68
+ listen 7860;\n\
69
+ server_name localhost;\n\
70
+ location / {\n\
71
+ proxy_pass http://nicegui;\n\
72
+ proxy_http_version 1.1;\n\
73
+ proxy_set_header Upgrade $http_upgrade;\n\
74
+ proxy_set_header Connection "upgrade";\n\
75
+ proxy_set_header Host $host;\n\
76
+ }\n\
77
+ location /proxy/3939/viewer {\n\
78
+ proxy_pass http://viewer/viewer;\n\
79
+ proxy_http_version 1.1;\n\
80
+ proxy_set_header Upgrade $http_upgrade;\n\
81
+ proxy_set_header Connection "upgrade";\n\
82
+ proxy_set_header Host $host;\n\
83
+ }\n\
84
+ }\n\
85
+ }' > /etc/nginx/nginx.conf
86
 
87
  # Create a test script for build-time verification
88
  RUN echo '#!/bin/bash\n\
 
95
  VIEWER_PID=$!\n\
96
  \n\
97
  echo "Starting nginx..."\n\
98
+ nginx -g "daemon off;" &\n\
99
+ NGINX_PID=$!\n\
100
  \n\
101
  echo "Waiting for servers to start..."\n\
102
  sleep 2\n\
 
109
  VIEWER_STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:7860/proxy/3939/viewer)\n\
110
  echo "Viewer status: $VIEWER_STATUS"\n\
111
  \n\
112
+ kill $NGINX_PID\n\
113
  kill $SERVER_PID $VIEWER_PID\n\
114
  \n\
115
  if [ "$MAIN_STATUS" = "200" ] && [ "$VIEWER_STATUS" = "200" ]; then\n\