forked from mtusi2026/mtusi2026lab3
перенос лабы 2
This commit is contained in:
+160
@@ -0,0 +1,160 @@
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16.15-alpine3.24@sha256:721873c34ceb9f8d8fc265984940dc982404c105f19ad51be9fdc5970a6080ea
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER:-messenger}
|
||||
POSTGRES_DB: ${POSTGRES_DB:-messenger}
|
||||
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
||||
secrets:
|
||||
- postgres_password
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test:
|
||||
[
|
||||
"CMD-SHELL",
|
||||
"pg_isready -U ${POSTGRES_USER:-messenger} -d ${POSTGRES_DB:-messenger}",
|
||||
]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 5s
|
||||
restart: unless-stopped
|
||||
|
||||
redis:
|
||||
image: redis:8.10.2-alpine3.23@sha256:3811787313eba226a2ef38658c6ccb91cd5e110edc89c37767de373120a0e5a0
|
||||
command:
|
||||
[
|
||||
"redis-server",
|
||||
"--save",
|
||||
"",
|
||||
"--appendonly",
|
||||
"no",
|
||||
"--maxmemory",
|
||||
"64mb",
|
||||
"--maxmemory-policy",
|
||||
"allkeys-lru",
|
||||
]
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 3s
|
||||
stop_grace_period: 10s
|
||||
restart: unless-stopped
|
||||
|
||||
migrate:
|
||||
image: migrate/migrate:v4.20.1@sha256:76cc2074cb6642631f34a898ced71e6aeaa6b1a4d78c4daa743275a22e0c5be7
|
||||
entrypoint: ["/bin/sh", "-ec"]
|
||||
command:
|
||||
- >
|
||||
exec migrate
|
||||
-path=/migrations
|
||||
-database="$$(cat /run/secrets/database_url)"
|
||||
up
|
||||
secrets:
|
||||
- database_url
|
||||
volumes:
|
||||
- ./migrations:/migrations:ro
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
restart: "no"
|
||||
|
||||
api:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
environment:
|
||||
APP_HOST: ${APP_HOST:-0.0.0.0}
|
||||
APP_PORT: ${APP_PORT:-8080}
|
||||
APP_ENV: ${APP_ENV:-lab}
|
||||
|
||||
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
||||
SESSION_STORE: ${SESSION_STORE:-postgres}
|
||||
|
||||
CACHE_URL: ${CACHE_URL:-redis://redis:6379/0}
|
||||
CACHE_TTL: ${CACHE_TTL:-5m}
|
||||
CACHE_OPERATION_TIMEOUT: ${CACHE_OPERATION_TIMEOUT:-250ms}
|
||||
CACHE_POOL_SIZE: ${CACHE_POOL_SIZE:-10}
|
||||
|
||||
DATABASE_URL_FILE: ${DATABASE_URL_FILE:-/run/secrets/database_url}
|
||||
|
||||
DB_MAX_CONNS: ${DB_MAX_CONNS:-10}
|
||||
DB_MIN_CONNS: ${DB_MIN_CONNS:-2}
|
||||
DB_MAX_CONN_LIFETIME: ${DB_MAX_CONN_LIFETIME:-30m}
|
||||
DB_MAX_CONN_IDLE_TIME: ${DB_MAX_CONN_IDLE_TIME:-5m}
|
||||
DB_HEALTH_CHECK_PERIOD: ${DB_HEALTH_CHECK_PERIOD:-30s}
|
||||
DB_CONNECT_TIMEOUT: ${DB_CONNECT_TIMEOUT:-5s}
|
||||
DB_QUERY_TIMEOUT: ${DB_QUERY_TIMEOUT:-3s}
|
||||
|
||||
READINESS_TIMEOUT: ${READINESS_TIMEOUT:-2s}
|
||||
SHUTDOWN_TIMEOUT: ${SHUTDOWN_TIMEOUT:-10s}
|
||||
secrets:
|
||||
- database_url
|
||||
ports:
|
||||
- "${APP_PORT:-8080}:${APP_PORT:-8080}"
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
healthcheck:
|
||||
test:
|
||||
[
|
||||
"CMD-SHELL",
|
||||
"wget -qO- http://127.0.0.1:$${APP_PORT:-8080}/health/ready || exit 1",
|
||||
]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 5s
|
||||
stop_grace_period: 15s
|
||||
restart: unless-stopped
|
||||
|
||||
redis-insight:
|
||||
image: redis/redisinsight:3.8.0@sha256:b5e19ee240abef6edb435871b90ff8a210995422e8e018ab61c0339d318a1f84
|
||||
profiles: ["tools"]
|
||||
ports:
|
||||
- "127.0.0.1:${REDIS_INSIGHT_PORT:-5540}:5540"
|
||||
volumes:
|
||||
- redis_insight_data:/data
|
||||
depends_on:
|
||||
redis:
|
||||
condition: service_healthy
|
||||
restart: unless-stopped
|
||||
|
||||
postgres-restore:
|
||||
image: postgres:16.15-alpine3.24@sha256:721873c34ceb9f8d8fc265984940dc982404c105f19ad51be9fdc5970a6080ea
|
||||
profiles: ["recovery"]
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER:-messenger}
|
||||
POSTGRES_DB: ${POSTGRES_RESTORE_DB:-messenger_restore_admin}
|
||||
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
||||
secrets:
|
||||
- postgres_password
|
||||
volumes:
|
||||
- postgres_restore_data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test:
|
||||
[
|
||||
"CMD-SHELL",
|
||||
"pg_isready -U ${POSTGRES_USER:-messenger} -d ${POSTGRES_RESTORE_DB:-messenger_restore_admin}",
|
||||
]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 5s
|
||||
restart: "no"
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
redis_insight_data:
|
||||
postgres_restore_data:
|
||||
|
||||
secrets:
|
||||
postgres_password:
|
||||
file: ./secrets/postgres_password.txt
|
||||
database_url:
|
||||
file: ./secrets/database_url.txt
|
||||
Reference in New Issue
Block a user