Skip to content

Commit 8c426c4

Browse files
authored
Update vm creation/add cache conf (#1703) [no ci]
* chore: update vm creation/add cache conf * Add newline
1 parent 2bf639e commit 8c426c4

5 files changed

Lines changed: 36 additions & 6 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ node_modules
99
.vscode
1010
*.env
1111
Resources/nginx/ssl/*
12-
!Resources/nginx/ssl/*.sample.*
12+
!Resources/nginx/ssl/*.prod.*
1313
.idea*
1414
data/v2/manifest.json*

‎Resources/gcp/create_gql_vm.sh‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ gcloud compute instances create graphql \
88
--boot-disk-size=20GB \
99
--boot-disk-type=pd-standard \
1010
--network-interface=network=default,subnet=default \
11-
--tags=http-server,https-server \
11+
--tags=https-server \
1212
--metadata=startup-script='#!/bin/bash
1313
set -euo pipefail
1414
15+
if [ -f /root/done ]; then
16+
exit 0
17+
fi
18+
1519
if [ ! -f /swapfile ]; then
1620
fallocate -l 1G /swapfile || dd if=/dev/zero of=/swapfile bs=1M count=1024
1721
chmod 600 /swapfile
@@ -22,7 +26,7 @@ fi
2226
2327
# Update and install prerequisite packages
2428
apt-get update
25-
apt-get install -y ca-certificates curl gnupg
29+
apt-get install -y ca-certificates curl gnupg make
2630
2731
# Add Docker official GPG key and repository
2832
install -m 0755 -d /etc/apt/keyrings
@@ -43,5 +47,19 @@ if [ ! -d /root/pokeapi ]; then
4347
git clone https://github.com/PokeAPI/pokeapi.git /root/pokeapi
4448
fi
4549
46-
touch /tmp/done
50+
curl -L https://raw.githubusercontent.com/hasura/graphql-engine/refs/heads/master/cli/get.sh | bash
51+
52+
cp /root/pokeapi/Resources/nginx/ssl/cache.prod.conf /root/pokeapi/Resources/nginx/ssl/cache.conf
53+
cp /root/pokeapi/Resources/nginx/ssl/ssl.prod.conf /root/pokeapi/Resources/nginx/ssl/ssl.conf
54+
55+
touch /root/done
56+
57+
# cd pokeapi
58+
# vi .env # POSTGRES_PASSWORD HASURA_GRAPHQL_ADMIN_SECRET
59+
# vi Resources/nginx/ssl/cert.cer # With CF gneerated certificate
60+
# vi Resources/nginx/ssl/key.key
61+
# set -a && source .env && set +a
62+
# make start-graphql-prod
63+
# make update-graphql-data-prod
64+
# Update DNS A record on CF with new IP address
4765
'

‎Resources/nginx/nginx-gql-v1beta.conf‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Deprecated v1beta
2+
13
worker_processes 1;
24

35
events {

‎Resources/nginx/nginx.conf‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ http {
4141
gzip_min_length 256;
4242
gzip_types application/atom+xml application/geo+json application/javascript application/x-javascript application/json application/ld+json application/manifest+json application/rdf+xml application/rss+xml application/xhtml+xml application/xml font/eot font/otf font/ttf image/svg+xml text/css text/javascript text/plain text/xml;
4343

44-
resolver 127.0.0.11 valid=10s;
44+
resolver 127.0.0.11 valid=1m;
4545

4646
geo $limit {
4747
default 1;
@@ -119,7 +119,17 @@ http {
119119

120120
location /v1beta2 {
121121
access_log /dev/stdout pokeapilogformat if=$only_post;
122-
include /ssl/cache.conf*;
122+
proxy_buffer_size 16k;
123+
proxy_buffers 8 16k;
124+
proxy_busy_buffers_size 112k;
125+
proxy_cache small;
126+
proxy_cache_valid 200 10d;
127+
proxy_cache_valid any 0;
128+
proxy_cache_methods POST;
129+
proxy_cache_key "$request_method$request_uri$request_body";
130+
proxy_cache_lock on;
131+
add_header X-Proxy-Cache $upstream_cache_status;
132+
add_header X-Cache-Date $upstream_http_date;
123133
limit_req zone=graphqlDefaultLimit burst=200 nodelay;
124134
limit_req_status 429;
125135
expires 30m;

0 commit comments

Comments
 (0)