From ebfdb3cee15b7566ad3785a96dd8c17c3bc387c4 Mon Sep 17 00:00:00 2001 From: masha Date: Fri, 30 Oct 2026 17:04:35 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=B5=D1=80=D0=BD=D1=83=D1=82=D1=8C=20?= =?UTF-8?q?=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20skeleton,=20=D0=B7=D0=B0=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D0=BD=D0=B8=D1=82=D1=8C=20.env.example=20=D0=B8=20?= =?UTF-8?q?=D0=B0=D0=B2=D1=82=D0=BE=D1=80=D0=B0=20=D0=B2=20=D0=BE=D1=82?= =?UTF-8?q?=D1=87=D1=91=D1=82=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- .env.example | 29 +++++++++++++++++++++++++++++ Dockerfile.example | 8 ++++++++ REPORT.md | 4 ++-- compose.example.yaml | 12 ++++++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 .env.example create mode 100644 Dockerfile.example create mode 100644 compose.example.yaml diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..e06560a7 --- /dev/null +++ b/.env.example @@ -0,0 +1,29 @@ +# Copy to .env for your LOCAL synthetic test environment; never commit .env. +# These are logical interface suggestions; map actual framework names in REPORT.md. +APP_HOST=0.0.0.0 +APP_PORT=8080 +APP_ENV=lab +SESSION_TTL_SECONDS=3600 +# Choose credentials locally. File paths contain no secret values. +DATABASE_URL_FILE=/run/secrets/database_url +# Optional on 3, required use on 4 in lab2; Redis OR Valkey: +SESSION_STORE=valkey +CACHE_URL_FILE=/run/secrets/cache_url +API_REPLICAS=2 +IDEMPOTENCY_TTL_SECONDS=86400 +S3_ENDPOINT=http://s3:9000 +S3_REGION=us-east-1 +S3_BUCKET=messenger-attachments +S3_ACCESS_KEY_ID_FILE=/run/secrets/s3_access_key_id +S3_SECRET_ACCESS_KEY_FILE=/run/secrets/s3_secret_access_key +MAX_UPLOAD_BYTES=10485760 +MAX_IMAGE_PIXELS=40000000 +# Public LB port on the host. If 8080 is busy, set e.g. 8081 and run make test with BASE_URL=http://localhost:8081 +LB_PORT=8080 +# Image tag of the api/migrate/s3-init services +APP_VERSION=dev +# Janitor of abandoned uploads (S3 PUT done, COMMIT never happened) +UPLOAD_GRACE_SECONDS=900 +JANITOR_INTERVAL_SECONDS=60 +# Experiments only, empty in normal operation: crash_after_s3_put | db_error_after_s3_put +FAULT_INJECTION= diff --git a/Dockerfile.example b/Dockerfile.example new file mode 100644 index 00000000..e333a12e --- /dev/null +++ b/Dockerfile.example @@ -0,0 +1,8 @@ +# Teaching outline, not a runnable Dockerfile. Implement your own Dockerfile. +# 1. Choose a runtime/toolchain version and pin the base image tag/digest. +# 2. Copy dependency manifests first; install from the language lockfile. +# 3. Copy source and build. For compiled languages use a separate runtime stage. +# 4. Run the HTTP process as PID 1; listen on 0.0.0.0:8080. +# 5. Add non-root, signals and healthcheck according to the current rubric. +# 6. Pass runtime config/secrets at startup, never COPY .env or secret files. +# This file deliberately has no FROM/CMD: selecting/implementing them is the task. diff --git a/REPORT.md b/REPORT.md index 77873c1c..8b8ccaef 100644 --- a/REPORT.md +++ b/REPORT.md @@ -1,8 +1,8 @@ # Отчёт — лабораторная 4 -- Автор, группа: Максимова, БВТ2303 (TODO: полное ФИО) +- Автор, группа: Максимова Мария, БВТ2303 - Целевая оценка; выбранный трек 5: 4 (трек не выбирается) -- Commit/PR: TODO после публикации (ветка `solution/maksimova_bvt2303`) +- Commit/PR: ветка `solution/maksimova_bvt2303` в fork https://gitea.privcloud.tech/Mariia_Maksimova/mtusi2026lab4, PR в `mtusi2026/mtusi2026lab4` (main) - Использованные источники, библиотеки и помощь ИИ: FastAPI, SQLAlchemy/asyncpg, argon2-cffi, redis-py, aiobotocore/botocore, Pillow (только для JPEG); SeaweedFS, PostgreSQL, Valkey, HAProxy. Документация: AWS S3 PutObject/SigV4, SeaweedFS wiki (S3 API, `s3.json` identities), спецификация PNG (RFC 2083), HAProxy 3.0 configuration manual. Помощь ИИ (Claude Code): ревью и доработка кода вложений, написание тестов в `student-tests/`, проведение экспериментов и черновик этого отчёта; все результаты получены реальными прогонами на стенде и проверены. ## Запуск из чистого clone diff --git a/compose.example.yaml b/compose.example.yaml new file mode 100644 index 00000000..76a785ff --- /dev/null +++ b/compose.example.yaml @@ -0,0 +1,12 @@ +# Topology worksheet, deliberately NOT a runnable stack (no application supplied). +# Implement compose.yaml or stack.yaml; do not submit this empty file as deployment. +# Service names below are logical roles, not imposed container names. +x-lab-number: 4 +x-required-roles: + - api + - postgres + - load_balancer + - s3 +# TODO: implement real images/builds, network wiring, volumes, healthchecks, +# credentials and bootstrap. Details: contracts/infrastructure.json and README.md. +services: {}