wjm55 commited on
Commit
e081ebf
·
1 Parent(s): 72f5836

Refactor Dockerfile and Nginx configuration to streamline service management. Remove supervisord integration, update CMD to directly start Weaviate and Nginx, and enhance Nginx settings for improved HTTP and gRPC handling.

Browse files
Files changed (2) hide show
  1. Dockerfile +17 -60
  2. nginx.conf +32 -16
Dockerfile CHANGED
@@ -1,72 +1,29 @@
 
1
  FROM cr.weaviate.io/semitechnologies/weaviate:1.30.0
2
 
3
- # Install Nginx and other utilities
4
  RUN apt-get update && \
5
- apt-get install -y nginx supervisor socat && \
6
- apt-get clean && \
7
- rm -rf /var/lib/apt/lists/*
8
 
9
- # Environment variables
10
  ENV QUERY_DEFAULTS_LIMIT=25 \
11
  AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED=true \
12
  PERSISTENCE_DATA_PATH=/var/lib/weaviate \
13
  ENABLE_API_BASED_MODULES=true \
14
- CLUSTER_HOSTNAME=node1 \
15
- GRPC_PORT=50051
16
 
17
- # Create data directory with proper permissions
18
- RUN mkdir -p /var/lib/weaviate && \
19
- chmod 777 /var/lib/weaviate
20
-
21
- # Copy the gRPC proxy script
22
- COPY grpc_proxy.sh /usr/local/bin/
23
- RUN chmod +x /usr/local/bin/grpc_proxy.sh
24
-
25
- # Nginx configuration
26
- RUN echo 'events { worker_connections 1024; }' > /etc/nginx/nginx.conf && \
27
- echo 'http { \
28
- server { \
29
- listen 7860; \
30
- location / { \
31
- proxy_pass http://localhost:8080; \
32
- proxy_set_header Host $host; \
33
- proxy_set_header X-Real-IP $remote_addr; \
34
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; \
35
- proxy_set_header X-Forwarded-Proto $scheme; \
36
- } \
37
- } \
38
- }' >> /etc/nginx/nginx.conf
39
-
40
- # Configure supervisord to run all services
41
- RUN echo '[supervisord]\n\
42
- nodaemon=true\n\
43
- \n\
44
- [program:weaviate]\n\
45
- command=/bin/weaviate --host 0.0.0.0 --port 8080 --scheme http\n\
46
- stdout_logfile=/dev/stdout\n\
47
- stdout_logfile_maxbytes=0\n\
48
- stderr_logfile=/dev/stderr\n\
49
- stderr_logfile_maxbytes=0\n\
50
- \n\
51
- [program:nginx]\n\
52
- command=/usr/sbin/nginx -g "daemon off;"\n\
53
- stdout_logfile=/dev/stdout\n\
54
- stdout_logfile_maxbytes=0\n\
55
- stderr_logfile=/dev/stderr\n\
56
- stderr_logfile_maxbytes=0\n\
57
- \n\
58
- [program:grpc_proxy]\n\
59
- command=/usr/local/bin/grpc_proxy.sh\n\
60
- stdout_logfile=/dev/stdout\n\
61
- stdout_logfile_maxbytes=0\n\
62
- stderr_logfile=/dev/stderr\n\
63
- stderr_logfile_maxbytes=0' > /etc/supervisor/conf.d/supervisord.conf
64
-
65
- # Create volume for persistent data
66
  VOLUME ["/var/lib/weaviate"]
67
 
68
- # Expose the main port
69
- EXPOSE 7860
 
 
 
70
 
71
- # Run all services using supervisord
72
- CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
 
 
 
1
+ # Base image with Weaviate
2
  FROM cr.weaviate.io/semitechnologies/weaviate:1.30.0
3
 
4
+ # Install nginx with grpc support
5
  RUN apt-get update && \
6
+ apt-get install -y nginx && \
7
+ apt-get clean
 
8
 
9
+ # Weaviate config
10
  ENV QUERY_DEFAULTS_LIMIT=25 \
11
  AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED=true \
12
  PERSISTENCE_DATA_PATH=/var/lib/weaviate \
13
  ENABLE_API_BASED_MODULES=true \
14
+ CLUSTER_HOSTNAME=node1
 
15
 
16
+ # Create data dir
17
+ RUN mkdir -p /var/lib/weaviate && chmod 777 /var/lib/weaviate
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  VOLUME ["/var/lib/weaviate"]
19
 
20
+ # Add NGINX config
21
+ COPY nginx.conf /etc/nginx/nginx.conf
22
+
23
+ # Expose only 7860 (used by nginx)
24
+ EXPOSE 7860
25
 
26
+ # Start script
27
+ CMD ["sh", "-c", "\
28
+ /bin/weaviate --host 127.0.0.1 --port 7860 --scheme http & \
29
+ nginx -g 'daemon off;'"]
nginx.conf CHANGED
@@ -1,26 +1,42 @@
 
 
1
  events {
2
  worker_connections 1024;
3
  }
4
 
5
  http {
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  server {
7
- listen 7860;
8
-
9
- # HTTP API proxy
10
- location / {
11
- proxy_pass http://weaviate:8080;
12
  proxy_set_header Host $host;
13
- proxy_set_header X-Real-IP $remote_addr;
14
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
15
- proxy_set_header X-Forwarded-Proto $scheme;
16
  }
17
- }
18
- }
19
 
20
- stream {
21
- # gRPC proxy
22
- server {
23
- listen 7861;
24
- proxy_pass weaviate:50051;
 
 
 
 
 
 
 
25
  }
26
- }
 
1
+ worker_processes 1;
2
+
3
  events {
4
  worker_connections 1024;
5
  }
6
 
7
  http {
8
+ include mime.types;
9
+ default_type application/octet-stream;
10
+
11
+ sendfile on;
12
+
13
+ upstream weaviate_http {
14
+ server 127.0.0.1:7860;
15
+ }
16
+
17
+ upstream weaviate_grpc {
18
+ server 127.0.0.1:50051;
19
+ }
20
+
21
  server {
22
+ listen 7860 http2;
23
+
24
+ location /v1/ {
25
+ proxy_pass http://weaviate_http;
 
26
  proxy_set_header Host $host;
 
 
 
27
  }
 
 
28
 
29
+ location / {
30
+ grpc_pass grpc://weaviate_grpc;
31
+ error_page 502 = /error502grpc;
32
+ }
33
+
34
+ location = /error502grpc {
35
+ internal;
36
+ default_type application/grpc;
37
+ add_header grpc-status 14;
38
+ add_header grpc-message "unavailable";
39
+ return 204;
40
+ }
41
  }
42
+ }