create tasks from 5

This commit is contained in:
EgorAnti
2026-11-03 20:49:07 +03:00
parent 6a4cd9534f
commit d235571a52
18 changed files with 1071 additions and 97 deletions
+3
View File
@@ -0,0 +1,3 @@
FROM nginx:1.27.4-bookworm
COPY swarm/nginx.conf /etc/nginx/nginx.conf
HEALTHCHECK --interval=2s --timeout=2s --retries=15 CMD nginx -t
+59
View File
@@ -0,0 +1,59 @@
worker_processes auto;
worker_shutdown_timeout 10s;
events {
worker_connections 1024;
}
http {
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log warn;
resolver 127.0.0.11 valid=2s ipv6=off;
resolver_timeout 1s;
upstream api_backend {
zone api_backend 64k;
least_conn;
server tasks.hla-app_api:8080 resolve max_fails=1 fail_timeout=2s;
keepalive 32;
}
server {
listen 80;
server_name _;
location = /nginx-health {
default_type application/json;
return 200 '{"status":"ok"}';
}
location ~ ^/api/v1/chats/[0-9a-fA-F-]+/messages$ {
proxy_pass http://api_backend;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_request_buffering on;
proxy_connect_timeout 500ms;
proxy_send_timeout 4s;
proxy_read_timeout 4s;
proxy_next_upstream error timeout http_502 http_503 http_504 non_idempotent;
proxy_next_upstream_tries 2;
}
location / {
proxy_pass http://api_backend;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 500ms;
proxy_send_timeout 4s;
proxy_read_timeout 4s;
proxy_next_upstream error timeout http_502 http_503 http_504;
proxy_next_upstream_tries 2;
}
}
}
+75
View File
@@ -0,0 +1,75 @@
version: "3.9"
services:
api:
image: hla-swarm-registry:5000/hla-lab3-api:swarm
environment:
APP_HOST: 0.0.0.0
APP_PORT: 8080
DATABASE_URL: jdbc:postgresql://hla-state_postgres:5432/${DATABASE_NAME:-messenger}
DATABASE_USER: ${DATABASE_USER:-messenger}
DATABASE_PASSWORD: ${DATABASE_PASSWORD:?DATABASE_PASSWORD is required}
DATABASE_POOL_SIZE: 10
DATABASE_MIN_IDLE: 2
DATABASE_QUERY_TIMEOUT_SECONDS: 5
DATABASE_TRANSACTION_TIMEOUT_SECONDS: 5
REDIS_HOST: hla-state_redis
REDIS_PORT: 6379
REDIS_CONNECT_TIMEOUT: 1s
REDIS_COMMAND_TIMEOUT: 500ms
SESSION_TTL_SECONDS: 3600
USER_CACHE_TTL_SECONDS: 300
IDEMPOTENCY_TTL_SECONDS: 86400
FLYWAY_ENABLED: "false"
healthcheck:
test: ["CMD", "curl", "--fail", "--silent", "http://localhost:8080/health/ready"]
interval: 2s
timeout: 2s
retries: 20
start_period: 45s
networks: [backend]
deploy:
replicas: 2
endpoint_mode: dnsrr
placement:
max_replicas_per_node: 1
restart_policy:
condition: on-failure
delay: 2s
update_config:
parallelism: 1
order: start-first
monitor: 15s
failure_action: rollback
rollback_config:
parallelism: 1
order: stop-first
resources:
limits:
cpus: "0.75"
memory: 768M
nginx:
image: hla-swarm-registry:5000/hla-lab3-nginx:swarm
ports:
- target: 80
published: 8080
protocol: tcp
mode: ingress
networks: [backend]
deploy:
replicas: 1
placement:
constraints:
- node.labels.hla.lb == true
restart_policy:
condition: on-failure
resources:
limits:
cpus: "0.25"
memory: 128M
networks:
backend:
external: true
name: hla-state_backend
+60
View File
@@ -0,0 +1,60 @@
version: "3.9"
services:
postgres:
image: postgres:16.4-bookworm
environment:
POSTGRES_DB: ${DATABASE_NAME:-messenger}
POSTGRES_USER: ${DATABASE_USER:-messenger}
POSTGRES_PASSWORD: ${DATABASE_PASSWORD:?DATABASE_PASSWORD is required}
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
interval: 2s
timeout: 2s
retries: 30
networks: [backend]
deploy:
replicas: 1
placement:
constraints:
- node.labels.hla.state == true
restart_policy:
condition: on-failure
resources:
limits:
cpus: "1.00"
memory: 768M
redis:
image: redis:7.4-bookworm
command: ["redis-server", "--appendonly", "yes", "--appendfsync", "everysec"]
volumes:
- redis-data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 2s
timeout: 2s
retries: 30
networks: [backend]
deploy:
replicas: 1
placement:
constraints:
- node.labels.hla.state == true
restart_policy:
condition: on-failure
resources:
limits:
cpus: "0.25"
memory: 256M
networks:
backend:
driver: overlay
attachable: true
volumes:
postgres-data:
redis-data: