API: use separate container for api in production

This commit is contained in:
Your Name 2024-01-28 10:17:11 -05:00 committed by Henri Dickson
parent ecc3fccbdf
commit 9660aee6a8
3 changed files with 18 additions and 1 deletions

View file

@ -169,6 +169,15 @@ services:
migration:
condition: service_completed_successfully
neodb-web-api:
<<: *neodb-service
command: ${NEODB_VENV:-/neodb-venv}/bin/gunicorn boofilsic.wsgi -w ${NEODB_API_WORKER_NUM:-4} --preload --max-requests 2000 -b 0.0.0.0:8000
healthcheck:
test: ['CMD', 'wget', '-qO/tmp/test', '--header', 'X-Forwarded-Proto: https', 'http://127.0.0.1:8000/nodeinfo/2.0/']
depends_on:
migration:
condition: service_completed_successfully
neodb-worker:
<<: *neodb-service
command: neodb-manage rqworker --with-scheduler import export mastodon fetch crawl ap cron
@ -205,6 +214,7 @@ services:
command: nginx-start
environment:
NEODB_WEB_SERVER: neodb-web:8000
NEODB_API_SERVER: neodb-web-api:8000
TAKAHE_WEB_SERVER: takahe-web:8000
NGINX_CONF: /neodb/misc/nginx.conf.d/neodb.conf
depends_on:

View file

@ -1,4 +1,4 @@
#!/bin/sh
chown app:app /www/media /www/m
envsubst '${NEODB_WEB_SERVER} ${TAKAHE_WEB_SERVER}' < $NGINX_CONF > /etc/nginx/conf.d/neodb.conf
envsubst '${NEODB_WEB_SERVER} ${NEODB_API_SERVER} ${TAKAHE_WEB_SERVER}' < $NGINX_CONF > /etc/nginx/conf.d/neodb.conf
nginx -g 'daemon off;'

View file

@ -4,6 +4,10 @@ upstream neodb {
server ${NEODB_WEB_SERVER};
}
upstream neodb-api {
server ${NEODB_API_SERVER};
}
upstream takahe {
server ${TAKAHE_WEB_SERVER};
}
@ -97,6 +101,9 @@ server {
location ~* ^/(static|@|\.well-known|actor|inbox|api/v1|api/v2|oauth|tags|settings|media|proxy|admin|djadmin) {
proxy_pass http://takahe;
}
location /api {
proxy_pass http://neodb-api;
}
location / {
proxy_pass http://neodb;
}