mirror of
https://github.com/PokeAPI/pokeapi
synced 2024-11-22 03:13:06 +00:00
chore: tweaks
This commit is contained in:
parent
655ff4f955
commit
5919d5a1b0
3 changed files with 21 additions and 49 deletions
|
@ -5,9 +5,6 @@ services:
|
||||||
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}"
|
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}"
|
||||||
POSTGRES_USER: "${POSTGRES_USER}"
|
POSTGRES_USER: "${POSTGRES_USER}"
|
||||||
|
|
||||||
app:
|
|
||||||
env_file: .env
|
|
||||||
|
|
||||||
web:
|
web:
|
||||||
volumes:
|
volumes:
|
||||||
- graphiql:/public-console:ro
|
- graphiql:/public-console:ro
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
worker_processes 2;
|
worker_processes 1;
|
||||||
|
|
||||||
events {
|
events {
|
||||||
worker_connections 4096;
|
worker_connections 1024;
|
||||||
multi_accept on; # accept each connection as soon as you can
|
multi_accept on; # accept each connection as soon as you can
|
||||||
accept_mutex off;
|
accept_mutex off;
|
||||||
use epoll;
|
use epoll;
|
||||||
|
@ -29,16 +29,16 @@ http {
|
||||||
gzip_disable "msi6";
|
gzip_disable "msi6";
|
||||||
gzip_vary on;
|
gzip_vary on;
|
||||||
gzip_proxied any;
|
gzip_proxied any;
|
||||||
gzip_comp_level 6;
|
gzip_comp_level 4;
|
||||||
gzip_buffers 16 8k;
|
gzip_buffers 16 8k;
|
||||||
gzip_http_version 1.1;
|
gzip_http_version 1.1;
|
||||||
gzip_min_length 256;
|
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;
|
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;
|
||||||
|
|
||||||
upstream pokeapi_upstream {
|
#upstream pokeapi_upstream {
|
||||||
# 'app' is the Django container name in Docker
|
# 'app' is the Django container name in Docker
|
||||||
server app:80 fail_timeout=0;
|
# server app:80 fail_timeout=0;
|
||||||
}
|
#}
|
||||||
|
|
||||||
upstream graphql_upstream {
|
upstream graphql_upstream {
|
||||||
server graphql-engine:8080 fail_timeout=0;
|
server graphql-engine:8080 fail_timeout=0;
|
||||||
|
@ -57,6 +57,7 @@ http {
|
||||||
|
|
||||||
limit_req_zone $limit_key zone=graphqlDefaultLimit:50m rate=1r/m;
|
limit_req_zone $limit_key zone=graphqlDefaultLimit:50m rate=1r/m;
|
||||||
limit_conn_zone $binary_remote_addr zone=addr:20m;
|
limit_conn_zone $binary_remote_addr zone=addr:20m;
|
||||||
|
proxy_cache_path /tmp/cache levels=1:2 keys_zone=small:40m inactive=10d max_size=2g use_temp_path=off;
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 80 deferred;
|
listen 80 deferred;
|
||||||
|
@ -67,7 +68,7 @@ http {
|
||||||
|
|
||||||
client_body_timeout 5s;
|
client_body_timeout 5s;
|
||||||
client_header_timeout 5s;
|
client_header_timeout 5s;
|
||||||
limit_conn addr 10;
|
limit_conn addr 15;
|
||||||
|
|
||||||
# Admin console
|
# Admin console
|
||||||
location /graphql/admin/ {
|
location /graphql/admin/ {
|
||||||
|
@ -91,11 +92,19 @@ http {
|
||||||
}
|
}
|
||||||
|
|
||||||
location /graphql/v1beta {
|
location /graphql/v1beta {
|
||||||
|
proxy_read_timeout 70s;
|
||||||
|
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";
|
||||||
limit_req zone=graphqlDefaultLimit burst=100 nodelay;
|
limit_req zone=graphqlDefaultLimit burst=100 nodelay;
|
||||||
limit_req_status 429;
|
limit_req_status 429;
|
||||||
expires 1m; # client-side caching, one minute for each API resource
|
expires 30m; # client-side caching, one minute for each API resource
|
||||||
add_header Cache-Control "public";
|
add_header Cache-Control "public";
|
||||||
add_header Pragma public;
|
add_header Pragma public;
|
||||||
|
add_header X-Proxy-Cache $upstream_cache_status;
|
||||||
|
add_header X-Cache-Date $upstream_http_date;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection "upgrade";
|
proxy_set_header Connection "upgrade";
|
||||||
|
@ -106,23 +115,9 @@ http {
|
||||||
proxy_pass http://graphql_upstream/v1/graphql;
|
proxy_pass http://graphql_upstream/v1/graphql;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /api/ {
|
|
||||||
expires 1m; # client-side caching, one minute for each API resource
|
|
||||||
add_header Cache-Control "public";
|
|
||||||
add_header Pragma public;
|
|
||||||
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_redirect off;
|
|
||||||
proxy_pass http://pokeapi_upstream;
|
|
||||||
}
|
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
return 404;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header Host $http_host;
|
|
||||||
proxy_redirect off;
|
|
||||||
proxy_pass http://pokeapi_upstream;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,25 +16,6 @@ services:
|
||||||
- pg_data:/var/lib/postgresql/data
|
- pg_data:/var/lib/postgresql/data
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
app:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: ./Resources/docker/app/Dockerfile
|
|
||||||
user: ${RUN_AS:-pokeapi}
|
|
||||||
environment:
|
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-pokemon}
|
|
||||||
POSTGRES_USER: ${POSTGRES_USER:-ash}
|
|
||||||
POSTGRES_DB: ${POSTGRES_DB:-pokeapi}
|
|
||||||
volumes:
|
|
||||||
- .:/code
|
|
||||||
links:
|
|
||||||
- db
|
|
||||||
- cache
|
|
||||||
depends_on:
|
|
||||||
- db
|
|
||||||
- cache
|
|
||||||
restart: always
|
|
||||||
|
|
||||||
web:
|
web:
|
||||||
image: nginx:alpine
|
image: nginx:alpine
|
||||||
ports:
|
ports:
|
||||||
|
@ -45,13 +26,12 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- ./Resources/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
- ./Resources/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||||
- ./Resources/nginx/ssl:/ssl:ro
|
- ./Resources/nginx/ssl:/ssl:ro
|
||||||
volumes_from:
|
|
||||||
- app:ro
|
|
||||||
links:
|
|
||||||
- app
|
|
||||||
|
|
||||||
graphql-engine:
|
graphql-engine:
|
||||||
image: hasura/graphql-engine:v2.0.0-alpha.5
|
image: hasura/graphql-engine:v2.0.0-alpha.5
|
||||||
|
cpus: 0.7
|
||||||
|
memswap_limit: 3g
|
||||||
|
mem_limit: 450m
|
||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- "8080:8080"
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|
Loading…
Reference in a new issue