Files
mtusi2026lab4/evidence/container.txt
T

164 lines
9.6 KiB
Plaintext

# Стенд: сервисы, порты, лимиты, секреты, миграции
# date: 2026-11-05T13:56:38Z
# commit: f8e41b1
$ docker compose ps -a --format table {{.Service}}\t{{.Name}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}
SERVICE NAME IMAGE STATUS PORTS
api messenger-lab4-api-1 mtusi-messenger-lab4-api:dev Up 11 seconds (healthy) 8080/tcp
api messenger-lab4-api-2 mtusi-messenger-lab4-api:dev Up 11 seconds (healthy) 8080/tcp
lb messenger-lab4-lb-1 haproxy:3.0.6-alpine Up 5 seconds 127.0.0.1:8080->8080/tcp
migrate messenger-lab4-migrate-1 mtusi-messenger-lab4-migrate:dev Exited (0) 12 seconds ago
postgres messenger-lab4-postgres-1 postgres:17.2-alpine Up 21 seconds (healthy) 5432/tcp
reconciler messenger-lab4-reconciler-1 mtusi-messenger-lab4-api:dev Up 11 seconds 8080/tcp
redis messenger-lab4-redis-1 redis:7.4.1-alpine Up 21 seconds (healthy) 6379/tcp
s3 messenger-lab4-s3-1 pgsty/minio:RELEASE.2026-08-04T00-00-00Z@sha256:b6bfe7239bfc83fb90d31612d9704d86039dd714f7904b3f1ad68f211e602372 Up 21 seconds (healthy) 9000/tcp
s3-init messenger-lab4-s3-init-1 pgsty/mc:RELEASE.2026-10-26T00-00-00Z@sha256:ce62c9053c69ce12a527a322345b5ad9f44b5f8a7b8189f82e516f2e3f30f1d8 Exited (0) 12 seconds ago
secrets-init messenger-lab4-secrets-init-1 alpine:3.20.3 Exited (0) 21 seconds ago
tools messenger-lab4-tools-run-3ba5514e0d22 mtusi-messenger-lab4-tools:dev Up 4 seconds
## CPU/RAM-лимиты (NanoCpus: 1e9 = 1 CPU; Memory в байтах)
$ sh -c docker inspect -f '{{.Name}} cpus={{.HostConfig.NanoCpus}} memory={{.HostConfig.Memory}}' $(docker compose ps -aq)
/messenger-lab4-api-1 cpus=500000000 memory=268435456
/messenger-lab4-api-2 cpus=500000000 memory=268435456
/messenger-lab4-lb-1 cpus=250000000 memory=67108864
/messenger-lab4-migrate-1 cpus=500000000 memory=536870912
/messenger-lab4-postgres-1 cpus=1000000000 memory=536870912
/messenger-lab4-reconciler-1 cpus=250000000 memory=134217728
/messenger-lab4-redis-1 cpus=250000000 memory=134217728
/messenger-lab4-s3-1 cpus=500000000 memory=536870912
/messenger-lab4-s3-init-1 cpus=250000000 memory=268435456
/messenger-lab4-secrets-init-1 cpus=100000000 memory=33554432
/messenger-lab4-tools-run-3ba5514e0d22 cpus=1000000000 memory=268435456
## container_name не задан (одно имя сервиса масштабируется)
$ sh -c docker compose config | grep -c container_name || true
0
## Секреты: каждый сервис видит только свои файлы
$ 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 run --rm --no-deps -T --entrypoint ls s3-init /run/secrets
s3_access_key_id
s3_root_password
s3_root_user
s3_secret_access_key
$ 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 postgres psql -U messenger -d messenger -c \d attachments -c \d message_attachments
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
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)
Check constraints:
"attachments_content_type_allowed" CHECK (content_type::text = ANY (ARRAY['image/png'::character varying, 'image/jpeg'::character varying]::text[]))
"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)
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 "message_attachments" CONSTRAINT "message_attachments_attachment_id_fkey" FOREIGN KEY (attachment_id) REFERENCES attachments(id) ON UPDATE CASCADE
Table "public.message_attachments"
Column | Type | Collation | Nullable | Default
---------------+----------+-----------+----------+---------
message_id | uuid | | not null |
position | smallint | | not null |
attachment_id | uuid | | not null |
Indexes:
"message_attachments_pkey" PRIMARY KEY, btree (message_id, "position")
"message_attachments_attachment_id_idx" btree (attachment_id)
"message_attachments_message_id_attachment_id_key" UNIQUE, btree (message_id, attachment_id)
Check constraints:
"message_attachments_position_range" CHECK ("position" >= 0 AND "position" <= 9)
Foreign-key constraints:
"message_attachments_attachment_id_fkey" FOREIGN KEY (attachment_id) REFERENCES attachments(id) ON UPDATE CASCADE
"message_attachments_message_id_fkey" FOREIGN KEY (message_id) REFERENCES messages(id) ON UPDATE CASCADE ON DELETE CASCADE
## Миграции: отдельный one-shot сервис, повторный запуск ничего не применяет
$ docker compose run --rm migrate
Container messenger-lab4-secrets-init-1 Created
Container messenger-lab4-postgres-1 Running
Container messenger-lab4-secrets-init-1 Starting
Container messenger-lab4-secrets-init-1 Started
Container messenger-lab4-secrets-init-1 Waiting
Container messenger-lab4-secrets-init-1 Exited
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "messenger", schema "public" at "postgres:5432"
4 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-05 13:56:26.122879+00
20261021010000_auth_sessions | 2026-11-05 13:56:26.136187+00
20261101000000_idempotency_keys | 2026-11-05 13:56:26.145579+00
20261105000000_attachments | 2026-11-05 13:56:26.159672+00
(4 rows)