lab 3 done
This commit is contained in:
+121
@@ -0,0 +1,121 @@
|
||||
version: '3.8'
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:17.6-alpine3.22
|
||||
environment:
|
||||
POSTGRES_USER: messenger
|
||||
POSTGRES_DB: messenger
|
||||
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
||||
secrets: [postgres_password]
|
||||
volumes: [postgres_data:/var/lib/postgresql/data]
|
||||
networks: [data]
|
||||
healthcheck:
|
||||
test: [CMD-SHELL, 'pg_isready -U messenger -d messenger']
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 15
|
||||
stop_grace_period: 20s
|
||||
deploy:
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints: [node.labels.mtusi_lab3_storage == true]
|
||||
resources:
|
||||
limits: {cpus: '1.0', memory: 512M}
|
||||
update_config: {parallelism: 1, order: stop-first}
|
||||
redis:
|
||||
image: redis:7.4.5-alpine3.21
|
||||
command: [redis-server, /usr/local/etc/redis/redis.conf]
|
||||
configs:
|
||||
- source: redis
|
||||
target: /usr/local/etc/redis/redis.conf
|
||||
volumes: [redis_data:/data]
|
||||
networks: [data]
|
||||
healthcheck:
|
||||
test: [CMD, redis-cli, ping]
|
||||
interval: 2s
|
||||
timeout: 1s
|
||||
retries: 15
|
||||
stop_grace_period: 20s
|
||||
deploy:
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints: [node.labels.mtusi_lab3_storage == true]
|
||||
resources:
|
||||
limits: {cpus: '0.5', memory: 128M}
|
||||
update_config: {parallelism: 1, order: stop-first}
|
||||
api:
|
||||
image: ${API_IMAGE:-mtusi-messenger:lab3}
|
||||
environment:
|
||||
INSTANCE_ID: '{{.Task.ID}}'
|
||||
POSTGRES_HOST: postgres
|
||||
POSTGRES_USER: messenger
|
||||
POSTGRES_DB: messenger
|
||||
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
||||
CURSOR_KEY_FILE: /run/secrets/cursor_key
|
||||
POSTGRES_MAX_CONNS: '10'
|
||||
REDIS_ADDR: redis:6379
|
||||
SESSION_TTL_SECONDS: '3600'
|
||||
QUERY_TIMEOUT_MS: '1000'
|
||||
secrets: [postgres_password, cursor_key]
|
||||
networks: [backend, data]
|
||||
stop_grace_period: 15s
|
||||
healthcheck:
|
||||
test: [CMD, wget, -q, -T, '2', -O, /dev/null, 'http://127.0.0.1:8080/health/ready']
|
||||
interval: 2s
|
||||
timeout: 3s
|
||||
start_period: 10s
|
||||
retries: 3
|
||||
deploy:
|
||||
replicas: ${API_REPLICAS:-2}
|
||||
endpoint_mode: dnsrr
|
||||
resources:
|
||||
limits: {cpus: '1.0', memory: 256M}
|
||||
restart_policy: {condition: any, delay: 1s}
|
||||
update_config:
|
||||
parallelism: 1
|
||||
order: start-first
|
||||
delay: 5s
|
||||
monitor: 15s
|
||||
failure_action: rollback
|
||||
rollback_config: {parallelism: 1, order: start-first}
|
||||
lb:
|
||||
image: haproxy:3.2.6-alpine
|
||||
configs:
|
||||
- source: haproxy
|
||||
target: /usr/local/etc/haproxy/haproxy.cfg
|
||||
networks: [backend]
|
||||
ports:
|
||||
- target: 8080
|
||||
published: ${PORT:-8080}
|
||||
protocol: tcp
|
||||
mode: host
|
||||
healthcheck:
|
||||
test: [CMD, haproxy, -c, -f, /usr/local/etc/haproxy/haproxy.cfg]
|
||||
interval: 5s
|
||||
timeout: 2s
|
||||
retries: 3
|
||||
deploy:
|
||||
replicas: 1
|
||||
resources:
|
||||
limits: {cpus: '0.5', memory: 128M}
|
||||
update_config: {parallelism: 1, order: stop-first}
|
||||
networks:
|
||||
backend:
|
||||
driver: overlay
|
||||
data:
|
||||
driver: overlay
|
||||
volumes:
|
||||
postgres_data:
|
||||
redis_data:
|
||||
configs:
|
||||
haproxy:
|
||||
file: ./infra/haproxy.cfg
|
||||
redis:
|
||||
file: ./infra/redis.conf
|
||||
secrets:
|
||||
postgres_password:
|
||||
external: true
|
||||
name: ${STACK_NAME:-mtusi-lab3}_postgres_password
|
||||
cursor_key:
|
||||
external: true
|
||||
name: ${STACK_NAME:-mtusi-lab3}_cursor_key
|
||||
Reference in New Issue
Block a user