forked from mtusi2026/mtusi2026lab2
Lab2- оценка 5
This commit is contained in:
+142
@@ -0,0 +1,142 @@
|
||||
name: mtusi-lab2
|
||||
|
||||
x-api-env: &api-env
|
||||
APP_HOST: 0.0.0.0
|
||||
APP_PORT: "8080"
|
||||
APP_ENV: ${APP_ENV:-lab}
|
||||
SESSION_STORE: ${SESSION_STORE:-valkey}
|
||||
SESSION_CACHE_MAX_TTL_SECONDS: ${SESSION_CACHE_MAX_TTL_SECONDS:-60}
|
||||
DB_MAX_CONNS: ${DB_MAX_CONNS:-10}
|
||||
DATABASE_URL_FILE: /run/secrets/database_url
|
||||
CACHE_URL_FILE: /run/secrets/cache_url
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:17.2-alpine3.21
|
||||
environment:
|
||||
POSTGRES_DB: messenger
|
||||
POSTGRES_USER: messenger
|
||||
POSTGRES_PASSWORD_FILE: /run/secrets/pg_password
|
||||
secrets: [pg_password]
|
||||
volumes:
|
||||
- pgdata:/var/lib/postgresql/data
|
||||
networks: [backend]
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U messenger -d messenger -h 127.0.0.1"]
|
||||
interval: 2s
|
||||
timeout: 3s
|
||||
retries: 30
|
||||
stop_grace_period: 30s
|
||||
restart: unless-stopped
|
||||
|
||||
valkey:
|
||||
image: valkey/valkey:8.0.2-alpine3.21
|
||||
command: ["valkey-server", "/usr/local/etc/valkey/valkey.conf"]
|
||||
volumes:
|
||||
- ./infra/valkey/valkey.conf:/usr/local/etc/valkey/valkey.conf:ro
|
||||
secrets: [valkey_auth]
|
||||
networks: [backend]
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "valkey-cli ping | grep -qE 'PONG|NOAUTH'"]
|
||||
interval: 2s
|
||||
timeout: 3s
|
||||
retries: 30
|
||||
restart: unless-stopped
|
||||
|
||||
migrate:
|
||||
build: .
|
||||
image: mtusi-messenger:lab2
|
||||
command: ["migrate"]
|
||||
environment:
|
||||
DATABASE_URL_FILE: /run/secrets/database_url
|
||||
secrets: [database_url]
|
||||
networks: [backend]
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
restart: "no"
|
||||
|
||||
api:
|
||||
build: .
|
||||
image: mtusi-messenger:lab2
|
||||
environment:
|
||||
<<: *api-env
|
||||
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
||||
secrets: [database_url, cache_url]
|
||||
ports:
|
||||
- "127.0.0.1:${APP_PORT:-8080}:8080"
|
||||
networks: [backend]
|
||||
depends_on:
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
valkey:
|
||||
condition: service_healthy
|
||||
stop_grace_period: 10s
|
||||
restart: unless-stopped
|
||||
|
||||
api-short-ttl:
|
||||
profiles: [ttl]
|
||||
image: mtusi-messenger:lab2
|
||||
environment:
|
||||
<<: *api-env
|
||||
SESSION_TTL_SECONDS: "2"
|
||||
SESSION_CACHE_MAX_TTL_SECONDS: "60"
|
||||
secrets: [database_url, cache_url]
|
||||
ports:
|
||||
- "127.0.0.1:8081:8080"
|
||||
networks: [backend]
|
||||
depends_on:
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
restart: unless-stopped
|
||||
|
||||
pg-research:
|
||||
profiles: [research]
|
||||
image: postgres:17.2-alpine3.21
|
||||
environment: &pg-env
|
||||
POSTGRES_DB: messenger
|
||||
POSTGRES_USER: messenger
|
||||
POSTGRES_PASSWORD_FILE: /run/secrets/pg_password
|
||||
secrets: [pg_password]
|
||||
shm_size: 256mb
|
||||
volumes:
|
||||
- pgresearch:/var/lib/postgresql/data
|
||||
- ./src/internal/db/migrations:/migrations:ro
|
||||
networks: [research]
|
||||
healthcheck: &pg-health
|
||||
test: ["CMD-SHELL", "pg_isready -U messenger -d messenger -h 127.0.0.1"]
|
||||
interval: 2s
|
||||
timeout: 3s
|
||||
retries: 30
|
||||
|
||||
pg-restore:
|
||||
profiles: [research]
|
||||
image: postgres:17.2-alpine3.21
|
||||
environment: *pg-env
|
||||
secrets: [pg_password]
|
||||
shm_size: 256mb
|
||||
volumes:
|
||||
- pgrestore:/var/lib/postgresql/data
|
||||
networks: [research]
|
||||
healthcheck: *pg-health
|
||||
|
||||
networks:
|
||||
backend: {}
|
||||
research: {}
|
||||
|
||||
volumes:
|
||||
pgdata: {}
|
||||
pgresearch: {}
|
||||
pgrestore: {}
|
||||
|
||||
secrets:
|
||||
pg_password:
|
||||
file: ./secrets/pg_password
|
||||
database_url:
|
||||
file: ./secrets/database_url
|
||||
cache_url:
|
||||
file: ./secrets/cache_url
|
||||
valkey_auth:
|
||||
file: ./secrets/valkey_auth.conf
|
||||
Reference in New Issue
Block a user