From 996b6986a40b7fd9daa7cee6c212fba927a21159 Mon Sep 17 00:00:00 2001 From: Naramsim Date: Wed, 22 Jan 2025 18:46:23 +0100 Subject: [PATCH 1/5] feat: new graphiql --- Resources/compose/docker-compose-prod-graphql.yml | 13 +++++++------ Resources/nginx/nginx.conf | 14 +++++++++++--- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Resources/compose/docker-compose-prod-graphql.yml b/Resources/compose/docker-compose-prod-graphql.yml index d149ecbf3..86aa29ed2 100644 --- a/Resources/compose/docker-compose-prod-graphql.yml +++ b/Resources/compose/docker-compose-prod-graphql.yml @@ -14,8 +14,10 @@ services: restart: "no" web: - volumes: - - graphiql:/public-console:ro + depends_on: + graphiql: + graphql-engine: + condition: service_healthy logging: driver: gcplogs @@ -30,10 +32,9 @@ services: HASURA_GRAPHQL_EVENTS_HTTP_POOL_SIZE: 10 graphiql: - image: pokeapi/graphiql:1.0.1 - command: sh -c 'cp -a /app/static/. /transfer/ && tail -f /etc/passwd' - volumes: - - graphiql:/transfer + image: pokeapi/graphiql:2.0.0 + expose: + - 80 depends_on: - graphql-engine restart: always diff --git a/Resources/nginx/nginx.conf b/Resources/nginx/nginx.conf index 0ce02689c..58b8307d1 100644 --- a/Resources/nginx/nginx.conf +++ b/Resources/nginx/nginx.conf @@ -47,6 +47,10 @@ http { server graphql-engine:8080 fail_timeout=0; } + upstream graphiql_upstream { + server graphiql:80 fail_timeout=0; + } + geo $limit { default 1; 10.0.0.0/8 0; @@ -99,9 +103,13 @@ http { } location /graphql/console { - alias /public-console; - index index.html; - try_files $uri $uri/ /index.html =405; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_pass http://graphiql_upstream/; } location /graphql/v1beta { From 6cba951db30ceded022ef0807bc6b32476caecd8 Mon Sep 17 00:00:00 2001 From: Naramsim Date: Wed, 22 Jan 2025 18:49:07 +0100 Subject: [PATCH 2/5] feat: increase rate limit --- Resources/nginx/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/nginx/nginx.conf b/Resources/nginx/nginx.conf index 58b8307d1..965547f62 100644 --- a/Resources/nginx/nginx.conf +++ b/Resources/nginx/nginx.conf @@ -115,7 +115,7 @@ http { location /graphql/v1beta { access_log /dev/stdout pokeapilogformat if=$only_post; include /ssl/cache.conf*; - limit_req zone=graphqlDefaultLimit burst=100 nodelay; + limit_req zone=graphqlDefaultLimit burst=200 nodelay; limit_req_status 429; expires 30m; add_header Cache-Control "public"; From 5c7e7ef9dfca62106c6676579249bf5febc7affe Mon Sep 17 00:00:00 2001 From: Naramsim Date: Wed, 22 Jan 2025 18:53:03 +0100 Subject: [PATCH 3/5] fix: add condition --- Resources/compose/docker-compose-prod-graphql.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/Resources/compose/docker-compose-prod-graphql.yml b/Resources/compose/docker-compose-prod-graphql.yml index 86aa29ed2..42447745a 100644 --- a/Resources/compose/docker-compose-prod-graphql.yml +++ b/Resources/compose/docker-compose-prod-graphql.yml @@ -16,6 +16,7 @@ services: web: depends_on: graphiql: + condition: service_started graphql-engine: condition: service_healthy logging: From c7500b336eb391260002542e9f0d1805fa96598e Mon Sep 17 00:00:00 2001 From: Naramsim Date: Wed, 22 Jan 2025 19:13:13 +0100 Subject: [PATCH 4/5] fix: wait for healthy db --- docker-compose.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 0af797e4c..90e1d374a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -55,7 +55,8 @@ services: ports: - "8080:8080" depends_on: - - "db" + db: + condition: service_healthy restart: always environment: HASURA_GRAPHQL_DATABASE_URL: postgres://${POSTGRES_USER:-ash}:${POSTGRES_PASSWORD:-pokemon}@db:5432/${POSTGRES_DB:-pokeapi} From bcc5ab491255569ab01b1756ae7288397b5f6dd7 Mon Sep 17 00:00:00 2001 From: Naramsim Date: Wed, 22 Jan 2025 19:13:24 +0100 Subject: [PATCH 5/5] fix: remove named volumes --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index a2b1b8bbf..527681033 100755 --- a/Makefile +++ b/Makefile @@ -140,6 +140,7 @@ start-graphql-prod: down-graphql-prod: docker container rm $(docker container ls -aq) -f docker system prune --all --volumes --force + docker volume prune --all --force sync; echo 3 > /proc/sys/vm/drop_caches # Nginx doesn't start if upstream graphql-engine is down