Files
mtusi2026lab5/evidence/container.txt
T

268 lines
18 KiB
Plaintext

# Стенд: сервисы, порты, лимиты, секреты, миграции, топология брокера
# date: 2026-11-16T13:59:25Z
# commit: 484119a
$ docker compose ps -a --format table {{.Service}}\t{{.Name}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}
SERVICE NAME IMAGE STATUS PORTS
api messenger-lab5-api-1 mtusi-messenger-lab5-api:dev Up 14 seconds (healthy) 8080/tcp
api messenger-lab5-api-2 mtusi-messenger-lab5-api:dev Up 15 seconds (healthy) 8080/tcp
lb messenger-lab5-lb-1 haproxy:3.0.6-alpine Up 8 seconds 127.0.0.1:8080->8080/tcp
migrate messenger-lab5-migrate-1 mtusi-messenger-lab5-migrate:dev Exited (0) 15 seconds ago
postgres messenger-lab5-postgres-1 postgres:17.2-alpine Up 24 seconds (healthy) 5432/tcp
rabbitmq messenger-lab5-rabbitmq-1 rabbitmq:4.0.5-alpine@sha256:e045b5166b9188a38eee5c99411709aa1f0ffa2ac75664053e64cb69411f7c32 Up 24 seconds (healthy) 4369/tcp, 5671-5672/tcp, 15691-15692/tcp, 25672/tcp
reconciler messenger-lab5-reconciler-1 mtusi-messenger-lab5-api:dev Up 15 seconds 8080/tcp
redis messenger-lab5-redis-1 redis:7.4.1-alpine Up 24 seconds (healthy) 6379/tcp
relay messenger-lab5-relay-1 mtusi-messenger-lab5-api:dev Up 9 seconds 8080/tcp
s3 messenger-lab5-s3-1 pgsty/minio:RELEASE.2026-08-04T00-00-00Z@sha256:b6bfe7239bfc83fb90d31612d9704d86039dd714f7904b3f1ad68f211e602372 Up 24 seconds (healthy) 9000/tcp
s3-init messenger-lab5-s3-init-1 pgsty/mc:RELEASE.2026-10-26T00-00-00Z@sha256:ce62c9053c69ce12a527a322345b5ad9f44b5f8a7b8189f82e516f2e3f30f1d8 Exited (0) 15 seconds ago
secrets-init messenger-lab5-secrets-init-1 alpine:3.20.3 Exited (0) 25 seconds ago
tools messenger-lab5-tools-run-ce3cefcdf49a mtusi-messenger-lab5-tools:dev Up 5 seconds
worker messenger-lab5-worker-1 mtusi-messenger-lab5-api:dev Up 9 seconds 8080/tcp
## CPU/RAM-лимиты (NanoCpus: 1e9 = 1 CPU; Memory в байтах)
$ sh -c docker inspect -f '{{.Name}} cpus={{.HostConfig.NanoCpus}} memory={{.HostConfig.Memory}}' $(docker compose ps -aq)
/messenger-lab5-api-1 cpus=500000000 memory=268435456
/messenger-lab5-api-2 cpus=500000000 memory=268435456
/messenger-lab5-lb-1 cpus=250000000 memory=67108864
/messenger-lab5-migrate-1 cpus=500000000 memory=536870912
/messenger-lab5-postgres-1 cpus=1000000000 memory=536870912
/messenger-lab5-rabbitmq-1 cpus=500000000 memory=536870912
/messenger-lab5-reconciler-1 cpus=250000000 memory=134217728
/messenger-lab5-redis-1 cpus=250000000 memory=134217728
/messenger-lab5-relay-1 cpus=250000000 memory=134217728
/messenger-lab5-s3-1 cpus=500000000 memory=536870912
/messenger-lab5-s3-init-1 cpus=250000000 memory=268435456
/messenger-lab5-secrets-init-1 cpus=100000000 memory=33554432
/messenger-lab5-tools-run-ce3cefcdf49a cpus=1000000000 memory=268435456
/messenger-lab5-worker-1 cpus=1000000000 memory=805306368
## Секреты: каждый сервис видит только свои файлы (содержимое не выводится)
$ docker compose exec -T postgres ls /run/secrets
pg_password
$ docker compose exec -T redis ls /run/secrets
redis_password
$ docker compose exec -T s3 ls /run/secrets
s3_root_password
s3_root_user
$ docker compose exec -T api ls /run/secrets
cache_url
database_url
s3_access_key_id
s3_secret_access_key
$ docker compose exec -T reconciler ls /run/secrets
database_url
s3_access_key_id
s3_secret_access_key
$ docker compose exec -T relay ls /run/secrets
broker_url
database_url
$ docker compose exec -T worker ls /run/secrets
broker_url
database_url
s3_access_key_id
s3_secret_access_key
$ docker compose exec -T rabbitmq ls /etc/rabbitmq/conf.d
10-messenger.conf
$ docker compose exec -T lb sh -c ls /run/secrets 2>/dev/null || echo "no /run/secrets"
no /run/secrets
## Версии
$ docker compose exec -T lb haproxy -v
HAProxy version 3.0.6-c2c0090 2024/11/07 - https://haproxy.org/
Status: long-term supported branch - will stop receiving fixes around Q2 2029.
Known bugs: http://www.haproxy.org/bugs/bugs-3.0.6.html
Running on: Linux 5.15.153.1-microsoft-standard-WSL2 #1 SMP Fri Mar 29 23:14:13 UTC 2024 x86_64
$ docker compose exec -T postgres postgres --version
postgres (PostgreSQL) 17.2
$ docker compose exec -T redis redis-server --version
Redis server v=7.4.1 sha=00000000:0 malloc=jemalloc-5.3.0 bits=64 build=a93ce81042b3a6d7
$ docker compose exec -T s3 minio --version
minio version RELEASE.2026-08-04T00-00-00Z (commit-id=d88f46ccee345a9c2fabe2d221d9a9e56bc11aec)
Runtime: go1.26.5 linux/amd64
License: GNU AGPLv3 - https://www.gnu.org/licenses/agpl-3.0.html
Copyright: 2015-2026 MinIO, Inc.
$ docker compose exec -T rabbitmq rabbitmqctl -q version
4.0.5
## Топология брокера: durable quorum-очереди, delivery-limit и DLQ
$ docker compose exec -T rabbitmq rabbitmqctl -q list_queues name type durable arguments messages
name type durable arguments messages
attachment.jobs quorum true [{"x-queue-type","quorum"},{"x-delivery-limit",20},{"x-dead-letter-exchange",[]},{"x-dead-letter-routing-key","attachment.jobs.dlq"}] 0
attachment.jobs.dlq quorum true [{"x-queue-type","quorum"}] 0
$ docker compose exec -T rabbitmq rabbitmqctl -q list_consumers queue_name prefetch_count ack_required
queue_name ack_required prefetch_count
attachment.jobs true 2
## Таблицы
$ docker compose exec -T postgres psql -U messenger -d messenger -c \d attachments -c \d attachment_variants -c \d attachment_jobs -c \d outbox -c \d job_events
Table "public.attachments"
Column | Type | Collation | Nullable | Default
--------------+-----------------------------+-----------+----------+-------------------
id | uuid | | not null |
chat_id | uuid | | not null |
owner_id | uuid | | not null |
filename | character varying(255) | | not null |
content_type | character varying(32) | | not null |
size_bytes | integer | | not null |
sha256 | character(64) | | not null |
object_key | character varying(128) | | not null |
created_at | timestamp(3) with time zone | | not null | CURRENT_TIMESTAMP
updated_at | timestamp(3) with time zone | | not null | CURRENT_TIMESTAMP
staging_key | character varying(128) | | |
status | character varying(16) | | not null |
error_code | character varying(64) | | |
Indexes:
"attachments_pkey" PRIMARY KEY, btree (id)
"attachments_chat_id_idx" btree (chat_id)
"attachments_object_key_key" UNIQUE, btree (object_key)
"attachments_owner_id_idx" btree (owner_id)
"attachments_staging_key_key" UNIQUE, btree (staging_key)
Check constraints:
"attachments_content_type_allowed" CHECK (content_type::text = ANY (ARRAY['image/png'::character varying, 'image/jpeg'::character varying]::text[]))
"attachments_error_code_when_failed" CHECK ((status::text = 'failed'::text) = (error_code IS NOT NULL))
"attachments_filename_not_blank" CHECK (btrim(filename::text) <> ''::text)
"attachments_sha256_format" CHECK (sha256 ~ '^[a-f0-9]{64}$'::text)
"attachments_size_range" CHECK (size_bytes >= 1 AND size_bytes <= 10485760)
"attachments_status_allowed" CHECK (status::text = ANY (ARRAY['queued'::character varying, 'processing'::character varying, 'ready'::character varying, 'failed'::character varying]::text[]))
Foreign-key constraints:
"attachments_chat_id_fkey" FOREIGN KEY (chat_id) REFERENCES chats(id) ON UPDATE CASCADE ON DELETE CASCADE
"attachments_owner_id_fkey" FOREIGN KEY (owner_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE RESTRICT
Referenced by:
TABLE "attachment_jobs" CONSTRAINT "attachment_jobs_attachment_id_fkey" FOREIGN KEY (attachment_id) REFERENCES attachments(id) ON UPDATE CASCADE ON DELETE CASCADE
TABLE "attachment_variants" CONSTRAINT "attachment_variants_attachment_id_fkey" FOREIGN KEY (attachment_id) REFERENCES attachments(id) ON UPDATE CASCADE ON DELETE CASCADE
TABLE "message_attachments" CONSTRAINT "message_attachments_attachment_id_fkey" FOREIGN KEY (attachment_id) REFERENCES attachments(id) ON UPDATE CASCADE
Table "public.attachment_variants"
Column | Type | Collation | Nullable | Default
------------------+-----------------------------+-----------+----------+-------------------
attachment_id | uuid | | not null |
pipeline_version | integer | | not null |
name | character varying(16) | | not null |
content_type | character varying(32) | | not null |
object_key | character varying(128) | | not null |
size_bytes | integer | | not null |
width | integer | | not null |
height | integer | | not null |
sha256 | character(64) | | not null |
created_at | timestamp(3) with time zone | | not null | CURRENT_TIMESTAMP
Indexes:
"attachment_variants_pkey" PRIMARY KEY, btree (attachment_id, pipeline_version, name)
"attachment_variants_object_key_key" UNIQUE, btree (object_key)
Check constraints:
"attachment_variants_content_type_allowed" CHECK (content_type::text = ANY (ARRAY['image/jpeg'::character varying, 'image/png'::character varying, 'image/webp'::character varying]::text[]))
"attachment_variants_name_allowed" CHECK (name::text = ANY (ARRAY['thumbnail'::character varying, 'crop'::character varying, 'optimized'::character varying]::text[]))
"attachment_variants_positive" CHECK (pipeline_version >= 1 AND size_bytes >= 1 AND width >= 1 AND height >= 1)
"attachment_variants_sha256_format" CHECK (sha256 ~ '^[a-f0-9]{64}$'::text)
Foreign-key constraints:
"attachment_variants_attachment_id_fkey" FOREIGN KEY (attachment_id) REFERENCES attachments(id) ON UPDATE CASCADE ON DELETE CASCADE
Table "public.attachment_jobs"
Column | Type | Collation | Nullable | Default
------------------+-----------------------------+-----------+----------+-------------------
id | uuid | | not null |
attachment_id | uuid | | not null |
pipeline_version | integer | | not null |
status | character varying(16) | | not null |
attempt | integer | | not null |
max_attempts | integer | | not null |
next_attempt_at | timestamp(3) with time zone | | not null |
lease_owner | uuid | | |
lease_until | timestamp(3) with time zone | | |
error_code | character varying(64) | | |
last_error | character varying(200) | | |
created_at | timestamp(3) with time zone | | not null | CURRENT_TIMESTAMP
updated_at | timestamp(3) with time zone | | not null | CURRENT_TIMESTAMP
finished_at | timestamp(3) with time zone | | |
Indexes:
"attachment_jobs_pkey" PRIMARY KEY, btree (id)
"attachment_jobs_attachment_id_pipeline_version_key" UNIQUE, btree (attachment_id, pipeline_version)
"attachment_jobs_status_lease_until_idx" btree (status, lease_until)
Check constraints:
"attachment_jobs_attempt_range" CHECK (pipeline_version >= 1 AND attempt >= 1 AND attempt <= max_attempts)
"attachment_jobs_error_code_when_failed" CHECK ((status::text = 'failed'::text) = (error_code IS NOT NULL))
"attachment_jobs_lease_when_processing" CHECK (status::text <> 'processing'::text OR lease_owner IS NOT NULL AND lease_until IS NOT NULL)
"attachment_jobs_status_allowed" CHECK (status::text = ANY (ARRAY['queued'::character varying, 'processing'::character varying, 'ready'::character varying, 'failed'::character varying]::text[]))
Foreign-key constraints:
"attachment_jobs_attachment_id_fkey" FOREIGN KEY (attachment_id) REFERENCES attachments(id) ON UPDATE CASCADE ON DELETE CASCADE
Referenced by:
TABLE "job_events" CONSTRAINT "job_events_job_id_fkey" FOREIGN KEY (job_id) REFERENCES attachment_jobs(id) ON UPDATE CASCADE ON DELETE CASCADE
TABLE "outbox" CONSTRAINT "outbox_job_id_fkey" FOREIGN KEY (job_id) REFERENCES attachment_jobs(id) ON UPDATE CASCADE ON DELETE CASCADE
Table "public.outbox"
Column | Type | Collation | Nullable | Default
------------------+-----------------------------+-----------+----------+------------------------------------
id | bigint | | not null | nextval('outbox_id_seq'::regclass)
job_id | uuid | | not null |
payload | jsonb | | not null |
available_at | timestamp(3) with time zone | | not null | CURRENT_TIMESTAMP
published_at | timestamp(3) with time zone | | |
publish_attempts | integer | | not null | 0
created_at | timestamp(3) with time zone | | not null | CURRENT_TIMESTAMP
Indexes:
"outbox_pkey" PRIMARY KEY, btree (id)
"outbox_job_id_idx" btree (job_id)
"outbox_published_at_available_at_idx" btree (published_at, available_at)
Foreign-key constraints:
"outbox_job_id_fkey" FOREIGN KEY (job_id) REFERENCES attachment_jobs(id) ON UPDATE CASCADE ON DELETE CASCADE
Table "public.job_events"
Column | Type | Collation | Nullable | Default
------------+-----------------------------+-----------+----------+----------------------------------------
id | bigint | | not null | nextval('job_events_id_seq'::regclass)
job_id | uuid | | not null |
attempt | integer | | not null |
event | character varying(32) | | not null |
detail | character varying(200) | | |
created_at | timestamp(3) with time zone | | not null | CURRENT_TIMESTAMP
Indexes:
"job_events_pkey" PRIMARY KEY, btree (id)
"job_events_job_id_idx" btree (job_id)
Foreign-key constraints:
"job_events_job_id_fkey" FOREIGN KEY (job_id) REFERENCES attachment_jobs(id) ON UPDATE CASCADE ON DELETE CASCADE
## Миграции: отдельный one-shot сервис, повторный запуск ничего не применяет, схема совпадает с БД
$ docker compose run --rm migrate
Container messenger-lab5-secrets-init-1 Created
Container messenger-lab5-postgres-1 Running
Container messenger-lab5-secrets-init-1 Starting
Container messenger-lab5-secrets-init-1 Started
Container messenger-lab5-secrets-init-1 Waiting
Container messenger-lab5-secrets-init-1 Exited
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "messenger", schema "public" at "postgres:5432"
5 migrations found in prisma/migrations
No pending migrations to apply.
$ docker compose run --rm --no-deps migrate sh -c export DATABASE_URL="$(cat "$DATABASE_URL_FILE")"; npx prisma migrate diff --from-url "$DATABASE_URL" --to-schema-datamodel prisma/schema.prisma --exit-code
No difference detected.
$ docker compose exec -T postgres psql -U messenger -d messenger -c SELECT migration_name, finished_at FROM _prisma_migrations ORDER BY started_at
migration_name | finished_at
---------------------------------+-------------------------------
20261021000000_init | 2026-11-16 13:59:09.682776+00
20261021010000_auth_sessions | 2026-11-16 13:59:09.695226+00
20261101000000_idempotency_keys | 2026-11-16 13:59:09.708431+00
20261105000000_attachments | 2026-11-16 13:59:09.722515+00
20261115000000_attachment_jobs | 2026-11-16 13:59:09.743001+00
(5 rows)