Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ node_modules
.vscode
*.env
Resources/nginx/ssl/*
!Resources/nginx/ssl/*.sample.*
!Resources/nginx/ssl/*.prod.*
.idea*
data/v2/manifest.json*
24 changes: 21 additions & 3 deletions Resources/gcp/create_gql_vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ gcloud compute instances create graphql \
--boot-disk-size=20GB \
--boot-disk-type=pd-standard \
--network-interface=network=default,subnet=default \
--tags=http-server,https-server \
--tags=https-server \
--metadata=startup-script='#!/bin/bash
set -euo pipefail

if [ -f /root/done ]; then
exit 0
fi

if [ ! -f /swapfile ]; then
fallocate -l 1G /swapfile || dd if=/dev/zero of=/swapfile bs=1M count=1024
chmod 600 /swapfile
Expand All @@ -22,7 +26,7 @@ fi

# Update and install prerequisite packages
apt-get update
apt-get install -y ca-certificates curl gnupg
apt-get install -y ca-certificates curl gnupg make

# Add Docker official GPG key and repository
install -m 0755 -d /etc/apt/keyrings
Expand All @@ -43,5 +47,19 @@ if [ ! -d /root/pokeapi ]; then
git clone https://github.com/PokeAPI/pokeapi.git /root/pokeapi
fi

touch /tmp/done
curl -L https://raw.githubusercontent.com/hasura/graphql-engine/refs/heads/master/cli/get.sh | bash

cp /root/pokeapi/Resources/nginx/ssl/cache.prod.conf /root/pokeapi/Resources/nginx/ssl/cache.conf
cp /root/pokeapi/Resources/nginx/ssl/ssl.prod.conf /root/pokeapi/Resources/nginx/ssl/ssl.conf

touch /root/done

# cd pokeapi
# vi .env # POSTGRES_PASSWORD HASURA_GRAPHQL_ADMIN_SECRET
# vi Resources/nginx/ssl/cert.cer # With CF gneerated certificate
# vi Resources/nginx/ssl/key.key
# set -a && source .env && set +a
# make start-graphql-prod
# make update-graphql-data-prod
# Update DNS A record on CF with new IP address
'
2 changes: 2 additions & 0 deletions Resources/nginx/nginx-gql-v1beta.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Deprecated v1beta

worker_processes 1;

events {
Expand Down
14 changes: 12 additions & 2 deletions Resources/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ http {
gzip_min_length 256;
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;

resolver 127.0.0.11 valid=10s;
resolver 127.0.0.11 valid=1m;

geo $limit {
default 1;
Expand Down Expand Up @@ -119,7 +119,17 @@ http {

location /v1beta2 {
access_log /dev/stdout pokeapilogformat if=$only_post;
include /ssl/cache.conf*;
proxy_buffer_size 16k;
proxy_buffers 8 16k;
proxy_busy_buffers_size 112k;
proxy_cache small;
proxy_cache_valid 200 10d;
proxy_cache_valid any 0;
proxy_cache_methods POST;
proxy_cache_key "$request_method$request_uri$request_body";
proxy_cache_lock on;
add_header X-Proxy-Cache $upstream_cache_status;
add_header X-Cache-Date $upstream_http_date;
limit_req zone=graphqlDefaultLimit burst=200 nodelay;
limit_req_status 429;
expires 30m;
Expand Down
File renamed without changes.
Loading