lab 2 solution
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
2026-10-23 17:24:27 +03:00
parent 65003b6119
commit 5c193f24f7
70 changed files with 7881 additions and 17 deletions
+566
View File
@@ -0,0 +1,566 @@
== 12: запуск из чистого clone ==
host: Windows 10 Pro 19045, x64, Git Bash; Docker 28.0.1 (Docker Desktop, WSL2)
date: 2026-10-11T19:43:28Z (UTC)
Что показывает: что получит человек, склонировавший репозиторий, — сборку образа
без кэша, миграции на пустом томе, публичный сценарий, проверку перезапуска и свои
проверки. Ничего из локального состояния (том .venv, secrets/, .env, кэш сборки) в
клон не переносится.
Оговорка. Закоммиченного состояния в этой работе нет — коммиты делает автор позже,
поэтому «клон» здесь — копия рабочего дерева без файлов, которые Git игнорирует
(.git, .venv, secrets/, .env, __pycache__). Для проверки это то же самое: в копии нет
ни одного файла, который не попадёт в репозиторий.
$ mkdir -p /c/Users/denis/AppData/Local/Temp/lab2-clean-clone && tar -c --exclude=.git --exclude=.venv --exclude=secrets \n --exclude=.env --exclude=__pycache__ --exclude="*.pyc" . | tar -x -C /c/Users/denis/AppData/Local/Temp/lab2-clean-clone
скопировано: 97 файлов, 706K
корень копии:
CONTRIBUTING.md
COURSE.md
Dockerfile
Dockerfile.example
MAINTAINERS.md
Makefile
README.md
REPORT.md
alembic.ini
compose.example.yaml
compose.yaml
contracts
evidence
examples
infra
lab.json
migrations
requirements-dev.txt
requirements.txt
scripts
src
student-tests
tests
Чего в копии нет (как и в клоне, пока автор не положил их рядом): secrets/, .env, .venv
$ docker compose stop # в основном репозитории: освобождаем порт 8080 и имя проекта
Container mtusi2026lab2-api-1 Stopping
Container mtusi2026lab2-api-1 Stopped
Container mtusi2026lab2-valkey-1 Stopping
Container mtusi2026lab2-migrate-1 Stopping
Container mtusi2026lab2-migrate-1 Stopped
Container mtusi2026lab2-postgres-1 Stopping
Container mtusi2026lab2-valkey-1 Stopped
Container mtusi2026lab2-postgres-1 Stopped
$ cd /c/Users/denis/AppData/Local/Temp/lab2-clean-clone
$ cp .env.example .env && sh scripts/bootstrap-secrets.sh
create secrets/postgres_password
create secrets/cursor_secret
create secrets/cache_url
create secrets/database_url
done: /c/Users/denis/AppData/Local/Temp/lab2-clean-clone/secrets
next: docker compose up -d --build
$ docker compose --env-file .env config --quiet # валидность до сборки
(пустой вывод, код 0)
$ time docker compose --env-file .env build --no-cache
Compose now can delegate build to bake for better performances
Just set COMPOSE_BAKE=true
#0 building with "desktop-linux" instance using docker driver
#1 [migrate internal] load build definition from Dockerfile
#1 transferring dockerfile: 2.13kB 0.0s done
#1 DONE 0.1s
#2 [migrate internal] load metadata for docker.io/library/python:3.11.9-slim-bookworm@sha256:8fb099199b9f2d70342674bd9dbccd3ed03a258f26bbd1d556822c6dfc60c317
#2 DONE 1.1s
#3 [migrate internal] load .dockerignore
#3 transferring context: 488B done
#3 DONE 0.1s
#4 [migrate runtime 2/7] WORKDIR /app
#4 CACHED
#5 [migrate builder 1/4] FROM docker.io/library/python:3.11.9-slim-bookworm@sha256:8fb099199b9f2d70342674bd9dbccd3ed03a258f26bbd1d556822c6dfc60c317
#5 resolve docker.io/library/python:3.11.9-slim-bookworm@sha256:8fb099199b9f2d70342674bd9dbccd3ed03a258f26bbd1d556822c6dfc60c317 0.1s done
#5 CACHED
#6 [migrate internal] load build context
#6 transferring context: 98.23kB 0.0s done
#6 DONE 0.1s
#7 [migrate builder 2/4] RUN python -m venv /opt/venv
#7 ...
#8 [migrate runtime 3/7] RUN useradd --create-home --uid 10001 --shell /usr/sbin/nologin app
#8 DONE 0.5s
#7 [migrate builder 2/4] RUN python -m venv /opt/venv
#7 DONE 4.6s
#9 [migrate builder 3/4] COPY requirements.txt ./
#9 DONE 0.1s
#10 [migrate builder 4/4] RUN /opt/venv/bin/pip install --no-cache-dir --timeout 60 -r requirements.txt
#10 1.038 Collecting alembic==1.16.5 (from -r requirements.txt (line 5))
#10 1.377 Downloading alembic-1.16.5-py3-none-any.whl.metadata (7.3 kB)
#10 1.441 Collecting annotated-doc==0.0.5 (from -r requirements.txt (line 6))
#10 1.502 Downloading annotated_doc-0.0.5-py3-none-any.whl.metadata (6.5 kB)
#10 1.572 Collecting annotated-types==0.8.0 (from -r requirements.txt (line 7))
#10 1.634 Downloading annotated_types-0.8.0-py3-none-any.whl.metadata (15 kB)
#10 1.725 Collecting anyio==4.15.1 (from -r requirements.txt (line 8))
#10 1.789 Downloading anyio-4.15.1-py3-none-any.whl.metadata (4.7 kB)
#10 1.869 Collecting argon2-cffi==25.1.0 (from -r requirements.txt (line 9))
#10 1.931 Downloading argon2_cffi-25.1.0-py3-none-any.whl.metadata (4.1 kB)
#10 2.002 Collecting argon2-cffi-bindings==26.1.0 (from -r requirements.txt (line 10))
#10 2.065 Downloading argon2_cffi_bindings-26.1.0-cp310-abi3-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.metadata (7.5 kB)
#10 2.218 Collecting asyncpg==0.30.0 (from -r requirements.txt (line 11))
#10 2.281 Downloading asyncpg-0.30.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (5.0 kB)
#10 2.502 Collecting cffi==2.1.1 (from -r requirements.txt (line 12))
#10 2.563 Downloading cffi-2.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.metadata (2.5 kB)
#10 2.636 Collecting click==8.5.0 (from -r requirements.txt (line 13))
#10 2.697 Downloading click-8.5.0-py3-none-any.whl.metadata (2.6 kB)
#10 2.824 Collecting fastapi==0.141.1 (from -r requirements.txt (line 14))
#10 2.886 Downloading fastapi-0.141.1-py3-none-any.whl.metadata (27 kB)
#10 3.171 Collecting greenlet==3.5.6 (from -r requirements.txt (line 15))
#10 3.234 Downloading greenlet-3.5.6-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.metadata (3.8 kB)
#10 3.299 Collecting h11==0.16.0 (from -r requirements.txt (line 16))
#10 3.364 Downloading h11-0.16.0-py3-none-any.whl.metadata (8.3 kB)
#10 3.435 Collecting idna==3.20 (from -r requirements.txt (line 17))
#10 3.497 Downloading idna-3.20-py3-none-any.whl.metadata (7.2 kB)
#10 3.570 Collecting Mako==1.4.3 (from -r requirements.txt (line 18))
#10 3.631 Downloading mako-1.4.3-py3-none-any.whl.metadata (2.9 kB)
#10 3.743 Collecting MarkupSafe==3.0.4 (from -r requirements.txt (line 19))
#10 3.804 Downloading markupsafe-3.0.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (2.7 kB)
#10 3.868 Collecting pycparser==3.11 (from -r requirements.txt (line 20))
#10 3.929 Downloading pycparser-3.11-py3-none-any.whl.metadata (8.2 kB)
#10 4.122 Collecting pydantic==2.14.0 (from -r requirements.txt (line 21))
#10 4.182 Downloading pydantic-2.14.0-py3-none-any.whl.metadata (131 kB)
#10 4.265 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 131.6/131.6 kB 1.6 MB/s eta 0:00:00
#10 5.185 Collecting pydantic_core==2.50.0 (from -r requirements.txt (line 22))
#10 5.250 Downloading pydantic_core-2.50.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.5 kB)
#10 5.347 Collecting redis==6.4.0 (from -r requirements.txt (line 23))
#10 5.409 Downloading redis-6.4.0-py3-none-any.whl.metadata (10 kB)
#10 5.857 Collecting SQLAlchemy==2.0.44 (from -r requirements.txt (line 24))
#10 5.920 Downloading sqlalchemy-2.0.44-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (9.5 kB)
#10 6.010 Collecting starlette==1.7.0 (from -r requirements.txt (line 25))
#10 6.071 Downloading starlette-1.7.0-py3-none-any.whl.metadata (6.6 kB)
#10 6.134 Collecting typing-inspection==0.4.4 (from -r requirements.txt (line 26))
#10 6.197 Downloading typing_inspection-0.4.4-py3-none-any.whl.metadata (2.6 kB)
#10 6.272 Collecting typing_extensions==4.16.0 (from -r requirements.txt (line 27))
#10 6.332 Downloading typing_extensions-4.16.0-py3-none-any.whl.metadata (3.3 kB)
#10 6.418 Collecting uvicorn==0.53.0 (from -r requirements.txt (line 28))
#10 6.479 Downloading uvicorn-0.53.0-py3-none-any.whl.metadata (6.6 kB)
#10 6.703 Downloading alembic-1.16.5-py3-none-any.whl (247 kB)
#10 6.777 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 247.4/247.4 kB 3.3 MB/s eta 0:00:00
#10 6.838 Downloading annotated_doc-0.0.5-py3-none-any.whl (5.3 kB)
#10 6.899 Downloading annotated_types-0.8.0-py3-none-any.whl (13 kB)
#10 6.960 Downloading anyio-4.15.1-py3-none-any.whl (132 kB)
#10 6.974 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 132.1/132.1 kB 10.2 MB/s eta 0:00:00
#10 7.034 Downloading argon2_cffi-25.1.0-py3-none-any.whl (14 kB)
#10 7.096 Downloading argon2_cffi_bindings-26.1.0-cp310-abi3-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl (26 kB)
#10 7.161 Downloading asyncpg-0.30.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB)
#10 7.538 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.1/3.1 MB 8.3 MB/s eta 0:00:00
#10 7.600 Downloading cffi-2.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (217 kB)
#10 7.617 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 217.8/217.8 kB 13.1 MB/s eta 0:00:00
#10 7.679 Downloading click-8.5.0-py3-none-any.whl (125 kB)
#10 7.689 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 125.3/125.3 kB 13.7 MB/s eta 0:00:00
#10 7.750 Downloading fastapi-0.141.1-py3-none-any.whl (131 kB)
#10 7.761 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 132.0/132.0 kB 13.4 MB/s eta 0:00:00
#10 7.823 Downloading greenlet-3.5.6-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (624 kB)
#10 7.948 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 624.4/624.4 kB 5.0 MB/s eta 0:00:00
#10 8.010 Downloading h11-0.16.0-py3-none-any.whl (37 kB)
#10 8.080 Downloading idna-3.20-py3-none-any.whl (69 kB)
#10 8.102 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 69.6/69.6 kB 3.5 MB/s eta 0:00:00
#10 8.163 Downloading mako-1.4.3-py3-none-any.whl (80 kB)
#10 8.188 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 80.2/80.2 kB 3.3 MB/s eta 0:00:00
#10 8.252 Downloading markupsafe-3.0.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (22 kB)
#10 8.317 Downloading pycparser-3.11-py3-none-any.whl (51 kB)
#10 8.333 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 51.2/51.2 kB 3.7 MB/s eta 0:00:00
#10 8.395 Downloading pydantic-2.14.0-py3-none-any.whl (487 kB)
#10 8.570 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 487.1/487.1 kB 2.8 MB/s eta 0:00:00
#10 8.632 Downloading pydantic_core-2.50.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB)
#10 9.173 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.2/2.2 MB 4.0 MB/s eta 0:00:00
#10 9.239 Downloading redis-6.4.0-py3-none-any.whl (279 kB)
#10 9.284 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 279.8/279.8 kB 6.3 MB/s eta 0:00:00
#10 9.346 Downloading sqlalchemy-2.0.44-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB)
#10 9.922 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.3/3.3 MB 5.8 MB/s eta 0:00:00
#10 9.983 Downloading starlette-1.7.0-py3-none-any.whl (78 kB)
#10 9.994 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 79.0/79.0 kB 8.0 MB/s eta 0:00:00
#10 10.06 Downloading typing_inspection-0.4.4-py3-none-any.whl (14 kB)
#10 10.12 Downloading typing_extensions-4.16.0-py3-none-any.whl (45 kB)
#10 10.12 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 45.6/45.6 kB 15.4 MB/s eta 0:00:00
#10 10.19 Downloading uvicorn-0.53.0-py3-none-any.whl (87 kB)
#10 10.19 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 87.1/87.1 kB 14.8 MB/s eta 0:00:00
#10 10.32 Installing collected packages: typing_extensions, redis, pycparser, MarkupSafe, idna, h11, greenlet, click, asyncpg, annotated-types, annotated-doc, uvicorn, typing-inspection, SQLAlchemy, pydantic_core, Mako, cffi, anyio, starlette, pydantic, argon2-cffi-bindings, alembic, fastapi, argon2-cffi
#10 12.63 Successfully installed Mako-1.4.3 MarkupSafe-3.0.4 SQLAlchemy-2.0.44 alembic-1.16.5 annotated-doc-0.0.5 annotated-types-0.8.0 anyio-4.15.1 argon2-cffi-25.1.0 argon2-cffi-bindings-26.1.0 asyncpg-0.30.0 cffi-2.1.1 click-8.5.0 fastapi-0.141.1 greenlet-3.5.6 h11-0.16.0 idna-3.20 pycparser-3.11 pydantic-2.14.0 pydantic_core-2.50.0 redis-6.4.0 starlette-1.7.0 typing-inspection-0.4.4 typing_extensions-4.16.0 uvicorn-0.53.0
#10 DONE 15.5s
#11 [migrate runtime 4/7] COPY --from=builder /opt/venv /opt/venv
#11 DONE 4.0s
#12 [migrate runtime 5/7] COPY --chown=app:app src/ ./src/
#12 DONE 0.3s
#13 [migrate runtime 6/7] COPY --chown=app:app alembic.ini ./
#13 DONE 0.4s
#14 [migrate runtime 7/7] COPY --chown=app:app migrations/ ./migrations/
#14 DONE 0.4s
#15 [migrate] exporting to image
#15 exporting layers
#15 exporting layers 6.0s done
#15 exporting manifest sha256:497714c4d6d7418762b653f07ea94c448f92f929a1caae79f3a80186f4ec97eb 0.1s done
#15 exporting config sha256:7f4549760fd2cd13e09f6df2097340279389796f0c0a89161a7256959b0b83e4 0.1s done
#15 exporting attestation manifest sha256:53ee5a784e528301b62ba62631f7d8e41f36288a118e130d55546275cd491723 0.1s done
#15 exporting manifest list sha256:072b4ca96ef50ee50ef92f2f350756cbf3083a8fdc948255ee8705e6927f0153
#15 exporting manifest list sha256:072b4ca96ef50ee50ef92f2f350756cbf3083a8fdc948255ee8705e6927f0153 0.1s done
#15 naming to docker.io/library/mtusi-messenger-lab2:2.0.0 0.0s done
#15 unpacking to docker.io/library/mtusi-messenger-lab2:2.0.0
#15 unpacking to docker.io/library/mtusi-messenger-lab2:2.0.0 1.6s done
#15 DONE 8.1s
#16 [migrate] resolving provenance for metadata file
#16 DONE 0.1s
#17 [api internal] load build definition from Dockerfile
#17 transferring dockerfile:
#17 transferring dockerfile: 2.13kB done
#17 DONE 0.2s
#2 [api internal] load metadata for docker.io/library/python:3.11.9-slim-bookworm@sha256:8fb099199b9f2d70342674bd9dbccd3ed03a258f26bbd1d556822c6dfc60c317
#2 DONE 1.2s
#18 [api internal] load .dockerignore
#18 transferring context: 488B done
#18 DONE 0.1s
#19 [api internal] load build context
#19 transferring context: 1.62kB done
#19 DONE 0.1s
#5 [api builder 1/4] FROM docker.io/library/python:3.11.9-slim-bookworm@sha256:8fb099199b9f2d70342674bd9dbccd3ed03a258f26bbd1d556822c6dfc60c317
#5 resolve docker.io/library/python:3.11.9-slim-bookworm@sha256:8fb099199b9f2d70342674bd9dbccd3ed03a258f26bbd1d556822c6dfc60c317
#5 resolve docker.io/library/python:3.11.9-slim-bookworm@sha256:8fb099199b9f2d70342674bd9dbccd3ed03a258f26bbd1d556822c6dfc60c317 0.2s done
#5 CACHED
#4 [api runtime 2/7] WORKDIR /app
#4 CACHED
#8 [api runtime 3/7] RUN useradd --create-home --uid 10001 --shell /usr/sbin/nologin app
#8 ...
#7 [api builder 2/4] RUN python -m venv /opt/venv
#7 ...
#8 [api runtime 3/7] RUN useradd --create-home --uid 10001 --shell /usr/sbin/nologin app
#8 DONE 12.9s
#7 [api builder 2/4] RUN python -m venv /opt/venv
#7 DONE 20.6s
#20 [api builder 3/4] COPY requirements.txt ./
#20 DONE 0.3s
#21 [api builder 4/4] RUN /opt/venv/bin/pip install --no-cache-dir --timeout 60 -r requirements.txt
#21 1.234 Collecting alembic==1.16.5 (from -r requirements.txt (line 5))
#21 1.409 Downloading alembic-1.16.5-py3-none-any.whl.metadata (7.3 kB)
#21 1.464 Collecting annotated-doc==0.0.5 (from -r requirements.txt (line 6))
#21 1.515 Downloading annotated_doc-0.0.5-py3-none-any.whl.metadata (6.5 kB)
#21 1.573 Collecting annotated-types==0.8.0 (from -r requirements.txt (line 7))
#21 1.623 Downloading annotated_types-0.8.0-py3-none-any.whl.metadata (15 kB)
#21 1.705 Collecting anyio==4.15.1 (from -r requirements.txt (line 8))
#21 1.752 Downloading anyio-4.15.1-py3-none-any.whl.metadata (4.7 kB)
#21 1.826 Collecting argon2-cffi==25.1.0 (from -r requirements.txt (line 9))
#21 1.875 Downloading argon2_cffi-25.1.0-py3-none-any.whl.metadata (4.1 kB)
#21 1.939 Collecting argon2-cffi-bindings==26.1.0 (from -r requirements.txt (line 10))
#21 1.988 Downloading argon2_cffi_bindings-26.1.0-cp310-abi3-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.metadata (7.5 kB)
#21 2.127 Collecting asyncpg==0.30.0 (from -r requirements.txt (line 11))
#21 2.179 Downloading asyncpg-0.30.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (5.0 kB)
#21 2.375 Collecting cffi==2.1.1 (from -r requirements.txt (line 12))
#21 2.423 Downloading cffi-2.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.metadata (2.5 kB)
#21 2.488 Collecting click==8.5.0 (from -r requirements.txt (line 13))
#21 2.538 Downloading click-8.5.0-py3-none-any.whl.metadata (2.6 kB)
#21 2.658 Collecting fastapi==0.141.1 (from -r requirements.txt (line 14))
#21 2.707 Downloading fastapi-0.141.1-py3-none-any.whl.metadata (27 kB)
#21 2.977 Collecting greenlet==3.5.6 (from -r requirements.txt (line 15))
#21 3.026 Downloading greenlet-3.5.6-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.metadata (3.8 kB)
#21 3.081 Collecting h11==0.16.0 (from -r requirements.txt (line 16))
#21 3.131 Downloading h11-0.16.0-py3-none-any.whl.metadata (8.3 kB)
#21 3.194 Collecting idna==3.20 (from -r requirements.txt (line 17))
#21 3.242 Downloading idna-3.20-py3-none-any.whl.metadata (7.2 kB)
#21 3.307 Collecting Mako==1.4.3 (from -r requirements.txt (line 18))
#21 3.358 Downloading mako-1.4.3-py3-none-any.whl.metadata (2.9 kB)
#21 3.462 Collecting MarkupSafe==3.0.4 (from -r requirements.txt (line 19))
#21 3.511 Downloading markupsafe-3.0.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (2.7 kB)
#21 3.567 Collecting pycparser==3.11 (from -r requirements.txt (line 20))
#21 3.617 Downloading pycparser-3.11-py3-none-any.whl.metadata (8.2 kB)
#21 3.792 Collecting pydantic==2.14.0 (from -r requirements.txt (line 21))
#21 3.847 Downloading pydantic-2.14.0-py3-none-any.whl.metadata (131 kB)
#21 3.912 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 131.6/131.6 kB 2.1 MB/s eta 0:00:00
#21 4.822 Collecting pydantic_core==2.50.0 (from -r requirements.txt (line 22))
#21 4.877 Downloading pydantic_core-2.50.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.5 kB)
#21 4.963 Collecting redis==6.4.0 (from -r requirements.txt (line 23))
#21 5.016 Downloading redis-6.4.0-py3-none-any.whl.metadata (10 kB)
#21 5.503 Collecting SQLAlchemy==2.0.44 (from -r requirements.txt (line 24))
#21 5.558 Downloading sqlalchemy-2.0.44-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (9.5 kB)
#21 5.646 Collecting starlette==1.7.0 (from -r requirements.txt (line 25))
#21 5.695 Downloading starlette-1.7.0-py3-none-any.whl.metadata (6.6 kB)
#21 5.750 Collecting typing-inspection==0.4.4 (from -r requirements.txt (line 26))
#21 5.801 Downloading typing_inspection-0.4.4-py3-none-any.whl.metadata (2.6 kB)
#21 5.867 Collecting typing_extensions==4.16.0 (from -r requirements.txt (line 27))
#21 5.917 Downloading typing_extensions-4.16.0-py3-none-any.whl.metadata (3.3 kB)
#21 6.001 Collecting uvicorn==0.53.0 (from -r requirements.txt (line 28))
#21 6.050 Downloading uvicorn-0.53.0-py3-none-any.whl.metadata (6.6 kB)
#21 6.271 Downloading alembic-1.16.5-py3-none-any.whl (247 kB)
#21 6.328 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 247.4/247.4 kB 4.3 MB/s eta 0:00:00
#21 6.383 Downloading annotated_doc-0.0.5-py3-none-any.whl (5.3 kB)
#21 6.432 Downloading annotated_types-0.8.0-py3-none-any.whl (13 kB)
#21 6.480 Downloading anyio-4.15.1-py3-none-any.whl (132 kB)
#21 6.491 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 132.1/132.1 kB 12.8 MB/s eta 0:00:00
#21 6.541 Downloading argon2_cffi-25.1.0-py3-none-any.whl (14 kB)
#21 6.589 Downloading argon2_cffi_bindings-26.1.0-cp310-abi3-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl (26 kB)
#21 6.658 Downloading asyncpg-0.30.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB)
#21 6.974 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.1/3.1 MB 9.9 MB/s eta 0:00:00
#21 7.022 Downloading cffi-2.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (217 kB)
#21 7.040 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 217.8/217.8 kB 12.8 MB/s eta 0:00:00
#21 7.089 Downloading click-8.5.0-py3-none-any.whl (125 kB)
#21 7.100 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 125.3/125.3 kB 12.2 MB/s eta 0:00:00
#21 7.150 Downloading fastapi-0.141.1-py3-none-any.whl (131 kB)
#21 7.160 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 132.0/132.0 kB 14.4 MB/s eta 0:00:00
#21 7.214 Downloading greenlet-3.5.6-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (624 kB)
#21 7.272 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 624.4/624.4 kB 10.9 MB/s eta 0:00:00
#21 7.320 Downloading h11-0.16.0-py3-none-any.whl (37 kB)
#21 7.370 Downloading idna-3.20-py3-none-any.whl (69 kB)
#21 7.375 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 69.6/69.6 kB 19.8 MB/s eta 0:00:00
#21 7.423 Downloading mako-1.4.3-py3-none-any.whl (80 kB)
#21 7.429 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 80.2/80.2 kB 17.6 MB/s eta 0:00:00
#21 7.480 Downloading markupsafe-3.0.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (22 kB)
#21 7.527 Downloading pycparser-3.11-py3-none-any.whl (51 kB)
#21 7.532 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 51.2/51.2 kB 12.0 MB/s eta 0:00:00
#21 7.583 Downloading pydantic-2.14.0-py3-none-any.whl (487 kB)
#21 7.623 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 487.1/487.1 kB 12.7 MB/s eta 0:00:00
#21 7.670 Downloading pydantic_core-2.50.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB)
#21 7.906 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.2/2.2 MB 9.2 MB/s eta 0:00:00
#21 7.955 Downloading redis-6.4.0-py3-none-any.whl (279 kB)
#21 7.984 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 279.8/279.8 kB 10.1 MB/s eta 0:00:00
#21 8.036 Downloading sqlalchemy-2.0.44-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB)
#21 8.452 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.3/3.3 MB 8.0 MB/s eta 0:00:00
#21 8.502 Downloading starlette-1.7.0-py3-none-any.whl (78 kB)
#21 8.511 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 79.0/79.0 kB 10.4 MB/s eta 0:00:00
#21 8.559 Downloading typing_inspection-0.4.4-py3-none-any.whl (14 kB)
#21 8.606 Downloading typing_extensions-4.16.0-py3-none-any.whl (45 kB)
#21 8.610 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 45.6/45.6 kB 13.6 MB/s eta 0:00:00
#21 8.662 Downloading uvicorn-0.53.0-py3-none-any.whl (87 kB)
#21 8.669 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 87.1/87.1 kB 16.0 MB/s eta 0:00:00
#21 8.794 Installing collected packages: typing_extensions, redis, pycparser, MarkupSafe, idna, h11, greenlet, click, asyncpg, annotated-types, annotated-doc, uvicorn, typing-inspection, SQLAlchemy, pydantic_core, Mako, cffi, anyio, starlette, pydantic, argon2-cffi-bindings, alembic, fastapi, argon2-cffi
#21 11.77 Successfully installed Mako-1.4.3 MarkupSafe-3.0.4 SQLAlchemy-2.0.44 alembic-1.16.5 annotated-doc-0.0.5 annotated-types-0.8.0 anyio-4.15.1 argon2-cffi-25.1.0 argon2-cffi-bindings-26.1.0 asyncpg-0.30.0 cffi-2.1.1 click-8.5.0 fastapi-0.141.1 greenlet-3.5.6 h11-0.16.0 idna-3.20 pycparser-3.11 pydantic-2.14.0 pydantic_core-2.50.0 redis-6.4.0 starlette-1.7.0 typing-inspection-0.4.4 typing_extensions-4.16.0 uvicorn-0.53.0
#21 DONE 20.1s
#22 [api runtime 4/7] COPY --from=builder /opt/venv /opt/venv
#22 DONE 11.4s
#23 [api runtime 5/7] COPY --chown=app:app src/ ./src/
#23 DONE 0.7s
#24 [api runtime 6/7] COPY --chown=app:app alembic.ini ./
#24 DONE 0.5s
#25 [api runtime 7/7] COPY --chown=app:app migrations/ ./migrations/
#25 DONE 0.4s
#26 [api] exporting to image
#26 exporting layers
#26 exporting layers 5.7s done
#26 exporting manifest sha256:13238cdec831519696e999a3bdf3a3c7209331cbe4b28cfe9fb88871f1584bcc 0.1s done
#26 exporting config sha256:1908c88271261d26061bdaaa56321dc5ab3ac239c694fb9697371e15072815a1 0.1s done
#26 exporting attestation manifest sha256:1a2008c82b4d08f46cb74800653a6b1e3e6d428aec3b77d858d26ee80f81d738 0.1s done
#26 exporting manifest list sha256:984dd8cb75bfce4be643e72e70c1b61eb5170691b324f399f61d7095e0a036ba
#26 exporting manifest list sha256:984dd8cb75bfce4be643e72e70c1b61eb5170691b324f399f61d7095e0a036ba 0.1s done
#26 naming to docker.io/library/mtusi-messenger-lab2:2.0.0 0.0s done
#26 unpacking to docker.io/library/mtusi-messenger-lab2:2.0.0
#26 unpacking to docker.io/library/mtusi-messenger-lab2:2.0.0 1.2s done
#26 DONE 7.4s
#27 [api] resolving provenance for metadata file
#27 DONE 0.0s
api Built
migrate Built
real 1m35.220s
user 0m0.015s
sys 0m0.091s
$ time docker compose --env-file .env up -d
Network lab2-clean-clone_backend Creating
Network lab2-clean-clone_backend Created
Volume "lab2-clean-clone_valkeydata" Creating
Volume "lab2-clean-clone_valkeydata" Created
Volume "lab2-clean-clone_pgdata" Creating
Volume "lab2-clean-clone_pgdata" Created
Container lab2-clean-clone-valkey-1 Creating
Container lab2-clean-clone-postgres-1 Creating
Container lab2-clean-clone-valkey-1 Created
Container lab2-clean-clone-postgres-1 Created
Container lab2-clean-clone-migrate-1 Creating
Container lab2-clean-clone-migrate-1 Created
Container lab2-clean-clone-api-1 Creating
Container lab2-clean-clone-api-1 Created
Container lab2-clean-clone-valkey-1 Starting
Container lab2-clean-clone-postgres-1 Starting
Container lab2-clean-clone-valkey-1 Started
Container lab2-clean-clone-postgres-1 Started
Container lab2-clean-clone-postgres-1 Waiting
Container lab2-clean-clone-postgres-1 Healthy
Container lab2-clean-clone-migrate-1 Starting
Container lab2-clean-clone-migrate-1 Started
Container lab2-clean-clone-postgres-1 Waiting
Container lab2-clean-clone-valkey-1 Waiting
Container lab2-clean-clone-migrate-1 Waiting
Container lab2-clean-clone-valkey-1 Healthy
Container lab2-clean-clone-postgres-1 Healthy
Container lab2-clean-clone-migrate-1 Exited
Container lab2-clean-clone-api-1 Starting
Container lab2-clean-clone-api-1 Started
real 0m19.129s
user 0m0.015s
sys 0m0.090s
$ docker compose --env-file .env ps --all
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
lab2-clean-clone-api-1 mtusi-messenger-lab2:2.0.0 "python -m messenger" api 8 seconds ago Up Less than a second (health: starting) 127.0.0.1:8080->8080/tcp
lab2-clean-clone-migrate-1 mtusi-messenger-lab2:2.0.0 "alembic upgrade head" migrate 8 seconds ago Exited (0) Less than a second ago
lab2-clean-clone-postgres-1 postgres:16.15-bookworm@sha256:0ea6700a3b4f0ae6ce746519073558aed4d88a79d8d07622a9a644946c7319c4 "docker-entrypoint.s…" postgres 19 seconds ago Up 7 seconds (healthy) 5432/tcp
lab2-clean-clone-valkey-1 valkey/valkey:8.0.11-trixie@sha256:4436c94fc34ce4af0354b9379d433a1f258998fb955f995c89822f98c14a8cab "tini -- docker-entr…" valkey 19 seconds ago Up 7 seconds (healthy) 6379/tcp
Ожидание готовности: опрос GET /health/ready раз в секунду
готов через 1 с (попытка 2)
$ curl -s http://127.0.0.1:8080/health/ready
{"status":"ok"}
$ python3 -m venv .venv && .venv/Scripts/python.exe -m pip install --quiet -r requirements-dev.txt
[notice] A new release of pip is available: 24.0 -> 26.2.1
[notice] To update, run: C:\Users\denis\AppData\Local\Temp\lab2-clean-clone\.venv\Scripts\python.exe -m pip install --upgrade pip
готово: Python 3.11.9
$ make check
python3 scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
$ make validate PYTHON=.venv/Scripts/python.exe
.venv/Scripts/python.exe scripts/validate_openapi.py
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.
$ make test BASE_URL=http://127.0.0.1:8080
python3 tests/smoke.py --base-url "http://127.0.0.1:8080"
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
$ make test-persistence ACTION_SCRIPT=scripts/restart.cmd BASE_URL=http://127.0.0.1:8080
# Тест запускает хук через Popen([script]) без оболочки, поэтому на Windows это
# .cmd-двойник scripts/restart.sh: CreateProcess умеет запускать .exe/.cmd/.bat,
# но не .sh. Сам POSIX-хук проверен ниже.
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.cmd" --base-url "http://127.0.0.1:8080"
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
$ sh scripts/restart.sh # тот же хук из POSIX-оболочки
=== services before restart ===
=== restart api postgres valkey (grace 10s) ===
Container lab2-clean-clone-valkey-1 Restarting
Container lab2-clean-clone-api-1 Restarting
Container lab2-clean-clone-postgres-1 Restarting
Container lab2-clean-clone-valkey-1 Started
Container lab2-clean-clone-postgres-1 Started
Container lab2-clean-clone-api-1 Started
=== services after restart ===
running services: api postgres valkey
restart complete
(строки таблицы docker compose ps опущены, полная таблица есть в доказательстве 02)
Ожидание готовности после хука
готов через 1 с
$ time make student-test BASE_URL=http://127.0.0.1:8080 PYTHON="python3 -X utf8"
Учётные данные Basic не должны открывать /users/me: челлендж должен требовать Bearer. ... ok
Маршрут входа принимает только Basic; сессионный токен не создаёт сессию. ... ok
Тот же статус, тот же код, то же сообщение — и сопоставимый объём работы. ... ok
Заголовок из лабораторной 1 не работает: не даёт доступа и не переопределяет сессию. ... ok
128 кириллических кодовых точек — это 256 байт UTF-8, и они проходят без потерь. ... ok
Пароль длиннее 72 байт не усекается KDF. ... ok
11 и 129 кодовых точек отклоняются; 12 и 128 принимаются. ... ok
Basic разделяет только по первому двоеточию, остальное принадлежит паролю. ... ok
Отказ зависимости не должен выглядеть для супервизора смертью процесса. ... skipped 'задайте ALLOW_OUTAGE=1 для запуска: этот модуль останавливает контейнеры'
api пересоздан с SESSION_TTL_SECONDS=3, готов через 3.69s
Пересоздание API не выдаёт новые сессии и не продлевает старые. ... у токена, выданного до переключения, осталось 3596s из исходных 3600s
Хранилище никто не чистит: ключа просто больше нет. ... ключ исчез сам между двумя запросами: приложение не удаляет просроченные сессии
api пересоздан с SESSION_TTL_SECONDS=3600, готов через 3.66s
Повторные пробы должен обслуживать процесс, а не кешированное тело. ... ok
Сессии не в памяти процесса: перезапуск только API их сохраняет. ... ok
16 входов подряд должны дать 16 разных токенов: повтор ломал бы отзыв. ... ok
----------------------------------------------------------------------
Ran 79 tests in 28.511s
OK (skipped=3)
real 0m28.818s
user 0m0.000s
sys 0m0.015s
$ docker compose --env-file .env stop # безопасная остановка: тома остаются
Container lab2-clean-clone-api-1 Stopping
Container lab2-clean-clone-api-1 Stopped
Container lab2-clean-clone-valkey-1 Stopping
Container lab2-clean-clone-migrate-1 Stopping
Container lab2-clean-clone-migrate-1 Stopped
Container lab2-clean-clone-postgres-1 Stopping
Container lab2-clean-clone-postgres-1 Stopped
Container lab2-clean-clone-valkey-1 Stopped
api | Exited (0) Less than a second ago
migrate | Exited (0) 21 seconds ago
postgres | Exited (0) Less than a second ago
valkey | Exited (0) Less than a second ago
$ docker volume ls --filter name=lab2-clean-clone --format "{{.Name}}"
lab2-clean-clone_pgdata
lab2-clean-clone_valkeydata
$ docker compose --env-file .env start # данные на месте, стенд снова жив
Container lab2-clean-clone-valkey-1 Healthy
Container lab2-clean-clone-migrate-1 Exited
Container lab2-clean-clone-api-1 Starting
Container lab2-clean-clone-api-1 Started
health/ready: 200
$ docker compose --env-file .env down # удаляет контейнеры, но не тома
Container lab2-clean-clone-valkey-1 Removed
Network lab2-clean-clone_backend Removing
Network lab2-clean-clone_backend Removed
тома после down:
lab2-clean-clone_pgdata
lab2-clean-clone_valkeydata
$ docker compose --env-file .env down -v # намеренное удаление учебных данных
Volume lab2-clean-clone_valkeydata Removing
Volume lab2-clean-clone_pgdata Removed
Volume lab2-clean-clone_valkeydata Removed
тома после down -v:
(ни одного)
Порядок именно такой: stop → down → down -v. Первые две команды данные сохраняют,
и ни один хук перезапуска в репозитории их не вызывает: scripts/restart.sh делает
только restart. Удаление -v здесь стоит последним шагом, потому что это учебный
стенд на одноразовой копии репозитория, а не рабочие данные.
$ cd /c/Users/denis/Desktop/HighLoad/mtusi2026lab2 && docker compose start # возвращаем основной стенд
Container mtusi2026lab2-postgres-1 Healthy
Container mtusi2026lab2-migrate-1 Exited
Container mtusi2026lab2-api-1 Starting
Container mtusi2026lab2-api-1 Started
основной стенд: готов через 2 с
Копия после прогона удалена: C:/Users/denis/AppData/Local/Temp/lab2-clean-clone