feat: lab3 init

This commit is contained in:
yurtaev.va
2026-10-23 18:54:43 +03:00
parent 0ab3a341aa
commit 2e23dbe095
16 changed files with 886 additions and 12 deletions
+21
View File
@@ -0,0 +1,21 @@
events { worker_connections 1024; }
http {
access_log off;
resolver 127.0.0.11 valid=1s ipv6=off;
server {
listen 8080;
client_max_body_size 16k;
proxy_connect_timeout 1s;
proxy_read_timeout 5s;
proxy_send_timeout 5s;
proxy_next_upstream error timeout http_502 http_503;
proxy_next_upstream_tries 2;
location / {
set $api http://api:8080;
proxy_pass $api;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Request-Id $request_id;
}
}
}
+66
View File
@@ -0,0 +1,66 @@
version: "3.8"
services:
api:
image: lab3-api:local
environment:
DATABASE_HOST: lab3data_postgres
DATABASE_NAME: messenger
DATABASE_USER: messenger
DATABASE_PASSWORD_FILE: /run/secrets/lab3_db_password
REDIS_URL: redis://lab3data_redis:6379/0
SESSION_TTL_SECONDS: "3600"
DB_POOL_SIZE: "8"
secrets: [lab3_db_password]
networks: [data]
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=2).close()"]
interval: 2s
timeout: 3s
retries: 2
deploy:
replicas: 2
placement:
constraints: [node.labels.lab3_compute == true]
update_config:
parallelism: 1
delay: 3s
order: start-first
failure_action: rollback
rollback_config:
parallelism: 1
order: start-first
restart_policy:
condition: on-failure
resources:
limits:
cpus: "0.75"
memory: 256M
lb:
image: nginx:1.27.5-alpine
configs:
- source: lab3_nginx_conf
target: /etc/nginx/nginx.conf
networks: [data]
ports:
- target: 8080
published: 8080
protocol: tcp
mode: host
deploy:
replicas: 1
placement:
constraints: [node.labels.lab3_storage == true]
resources:
limits:
cpus: "0.5"
memory: 128M
networks:
data:
external: true
name: lab3data_data
secrets:
lab3_db_password:
external: true
configs:
lab3_nginx_conf:
external: true
+41
View File
@@ -0,0 +1,41 @@
version: "3.8"
services:
postgres:
image: postgres:16.8-alpine
environment:
POSTGRES_DB: messenger
POSTGRES_USER: messenger
POSTGRES_PASSWORD_FILE: /run/secrets/lab3_db_password
secrets: [lab3_db_password]
volumes:
- postgres_data:/var/lib/postgresql/data
networks: [data]
deploy:
replicas: 1
placement:
constraints: [node.labels.lab3_storage == true]
resources:
limits:
cpus: "1.0"
memory: 512M
redis:
image: redis:7.4.2-alpine
command: ["redis-server", "--save", "", "--appendonly", "no", "--maxmemory", "128mb", "--maxmemory-policy", "allkeys-lru"]
networks: [data]
deploy:
replicas: 1
placement:
constraints: [node.labels.lab3_storage == true]
resources:
limits:
cpus: "0.5"
memory: 192M
networks:
data:
driver: overlay
attachable: true
volumes:
postgres_data:
secrets:
lab3_db_password:
external: true