Make frontend nginx conf suitable for k8s or local deployment (no need for 'old' deployment bits)

This commit is contained in:
James Wilson
2021-08-14 11:57:52 +01:00
parent 8793d0fd5b
commit 53f7769146
7 changed files with 12 additions and 112 deletions
+1 -1
View File
@@ -126,7 +126,7 @@ If you'd like to get things runing manually using Docker, you can do the followi
```
docker run --rm -it --network=telemetry \
--name frontend \
-p 3000:80 \
-p 3000:8000 \
-e SUBSTRATE_TELEMETRY_URL=ws://localhost:8000/feed \
substrate-telemetry-frontend
```
+1 -8
View File
@@ -5,15 +5,8 @@ services:
build:
dockerfile: Dockerfile
context: ./frontend/
# Copy in changes to the ui, so no need to rebuild the images.
volumes:
- /app/node_modules
- ./packages:/app/packages
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/default:/etc/nginx/sites-available/default
- ./env-config.js:/usr/share/nginx/html/env-config.js
ports:
- 3000:80
- 3000:8000
expose:
- 3000
telemetry-backend-shard:
+1 -2
View File
@@ -25,9 +25,8 @@ COPY --from=builder /opt/builder/env.sh /usr/bin/
RUN apk add --no-cache bash; chmod +x /usr/bin/env.sh
COPY --from=builder /opt/builder/nginx/nginx.conf /etc/nginx/nginx.conf
COPY --from=builder /opt/builder/nginx/default /etc/nginx/sites-available/default
COPY --from=builder /opt/builder/build /usr/share/nginx/html
EXPOSE 80
EXPOSE 8000
CMD ["/bin/bash", "-c", "/usr/bin/env.sh && nginx -g \"daemon off;\""]
-48
View File
@@ -1,48 +0,0 @@
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
server {
root /usr/share/nginx/html;
index index.html;
listen 3000;
listen [::]:3000;
server_name telemetry.polkadot.io localhost;
location /feed/ {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
limit_req zone=zone burst=5;
}
location /submit/ {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
limit_req zone=zone burst=5;
}
location /health/ {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
limit_req zone=zone burst=5;
}
}
+9 -3
View File
@@ -10,19 +10,25 @@ events {
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/mime.types;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip on;
include /etc/nginx/conf.d/*.conf;
server {
root /usr/share/nginx/html;
index index.html;
listen 8000;
listen [::]:8000;
server_name telemetry.polkadot.io localhost;
}
}
-9
View File
@@ -54,17 +54,8 @@ spec:
httpGet:
path: /
port: http
volumeMounts:
- name: nginx
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
readOnly: true
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: nginx
configMap:
name: frontend-nginx
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
@@ -1,41 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: frontend-nginx
data:
nginx.conf: |
user nginx;
worker_processes auto;
worker_rlimit_nofile 30000;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 8000;
}
http {
default_type application/octet-stream;
include /etc/nginx/mime.types;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip on;
include /etc/nginx/conf.d/*.conf;
#server_tokens off;
server {
root /usr/share/nginx/html;
index index.html;
listen 8000;
server_name _;
location = /favicon.ico {
return 204;
}
}
}