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 diff --git a/Resources/compose/docker-compose-prod-graphql.yml b/Resources/compose/docker-compose-prod-graphql.yml index d149ecbf3..42447745a 100644 --- a/Resources/compose/docker-compose-prod-graphql.yml +++ b/Resources/compose/docker-compose-prod-graphql.yml @@ -14,8 +14,11 @@ services: restart: "no" web: - volumes: - - graphiql:/public-console:ro + depends_on: + graphiql: + condition: service_started + graphql-engine: + condition: service_healthy logging: driver: gcplogs @@ -30,10 +33,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..965547f62 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,15 +103,19 @@ 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 { 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"; 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}