feat(infra): add nginx load balancer and two api replicas
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
events {}
|
||||||
|
|
||||||
|
http {
|
||||||
|
resolver 127.0.0.11 valid=2s ipv6=off;
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 8080;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
set $backend http://api:8080;
|
||||||
|
proxy_pass $backend;
|
||||||
|
|
||||||
|
proxy_connect_timeout 1s;
|
||||||
|
proxy_read_timeout 6s;
|
||||||
|
proxy_next_upstream error timeout http_502 http_503;
|
||||||
|
proxy_next_upstream_tries 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+14
-3
@@ -3,14 +3,14 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
image: mtusi-messenger:lab2
|
image: mtusi-messenger:lab3
|
||||||
ports:
|
|
||||||
- "127.0.0.1:8080:${APP_PORT}"
|
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
secrets:
|
secrets:
|
||||||
- database_url
|
- database_url
|
||||||
- cache_url
|
- cache_url
|
||||||
|
deploy:
|
||||||
|
replicas: ${API_REPLICAS:-2}
|
||||||
depends_on:
|
depends_on:
|
||||||
migrate:
|
migrate:
|
||||||
condition: service_completed_successfully
|
condition: service_completed_successfully
|
||||||
@@ -56,6 +56,17 @@ services:
|
|||||||
retries: 10
|
retries: 10
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
|
load_balancer:
|
||||||
|
image: nginx:1.31.7-alpine3.24
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:8080:8080"
|
||||||
|
volumes:
|
||||||
|
- ./deploy/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||||
|
depends_on:
|
||||||
|
api:
|
||||||
|
condition: service_healthy
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
secrets:
|
secrets:
|
||||||
postgres_password:
|
postgres_password:
|
||||||
file: ./secrets/postgres_password.txt
|
file: ./secrets/postgres_password.txt
|
||||||
|
|||||||
Reference in New Issue
Block a user