forked from mtusi2026/mtusi2026lab3
193 lines
9.0 KiB
Plaintext
193 lines
9.0 KiB
Plaintext
$ echo "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME (отдельный проект: рабочий стенд не затрагивается)"
|
|
COMPOSE_PROJECT_NAME=lab3-clean (отдельный проект: рабочий стенд не затрагивается)
|
|
$ cp .env.example .env && sed -i "" "s/^DB_PASS=.*/DB_PASS=$(openssl rand -hex 16)/; s/^VALKEY_PASS=.*/VALKEY_PASS=$(openssl rand -hex 16)/; s/^LB_PORT=.*/LB_PORT=18080/" .env && echo "LB_EXPIRY_PORT=18081" >> .env && echo ".env created from .env.example with random synthetic secrets"
|
|
.env created from .env.example with random synthetic secrets
|
|
$ docker compose --env-file .env config --quiet && echo "compose config: OK"
|
|
compose config: OK
|
|
$ make up
|
|
docker compose up -d --build --wait
|
|
#1 [internal] load local bake definitions
|
|
#1 reading from stdin 1.47kB done
|
|
#1 DONE 0.0s
|
|
|
|
#2 [api internal] load build definition from Dockerfile
|
|
#2 transferring dockerfile: 914B done
|
|
#2 DONE 0.0s
|
|
|
|
#3 [api internal] load metadata for docker.io/library/python:3.12.12-slim-bookworm
|
|
#3 DONE 0.0s
|
|
|
|
#4 [api internal] load .dockerignore
|
|
#4 transferring context: 358B done
|
|
#4 DONE 0.0s
|
|
|
|
#5 [api 1/7] FROM docker.io/library/python:3.12.12-slim-bookworm@sha256:593bd06efe90efa80dc4eee3948be7c0fde4134606dd40d8dd8dbcade98e669c
|
|
#5 resolve docker.io/library/python:3.12.12-slim-bookworm@sha256:593bd06efe90efa80dc4eee3948be7c0fde4134606dd40d8dd8dbcade98e669c done
|
|
#5 DONE 0.0s
|
|
|
|
#6 [api internal] load build context
|
|
#6 transferring context: 184.06kB 0.0s done
|
|
#6 DONE 0.0s
|
|
|
|
#7 [api 2/7] WORKDIR /app
|
|
#7 CACHED
|
|
|
|
#8 [api 4/7] RUN pip install --no-cache-dir --timeout 60 --retries 10 "poetry==2.2.1" && poetry install --only main --no-root --no-interaction
|
|
#8 CACHED
|
|
|
|
#9 [api 3/7] COPY poetry.lock pyproject.toml ./
|
|
#9 CACHED
|
|
|
|
#10 [migrate 5/7] COPY migrations ./migrations
|
|
#10 CACHED
|
|
|
|
#11 [migrate 6/7] COPY src ./src
|
|
#11 DONE 0.0s
|
|
|
|
#12 [api 7/7] RUN useradd --system --uid 10001 --no-create-home app
|
|
#12 0.118 useradd warning: app's uid 10001 is greater than SYS_UID_MAX 999
|
|
#12 DONE 0.1s
|
|
|
|
#13 [migrate] exporting to image
|
|
#13 exporting layers 0.0s done
|
|
#13 exporting manifest sha256:a99a66062da552c44bf2543747fc3ac215605d7487b93882f0248f46ae71dbf5 done
|
|
#13 exporting config sha256:53e2ac5d5830524705f0737d78b69d4f9c1ca9670b8a24788c8717a7d772898f done
|
|
#13 naming to docker.io/library/mtusi-messenger:lab3 done
|
|
#13 unpacking to docker.io/library/mtusi-messenger:lab3 0.0s done
|
|
#13 DONE 0.1s
|
|
|
|
#14 [api] exporting to image
|
|
#14 exporting layers 0.0s done
|
|
#14 exporting manifest sha256:47e4d0732ca8d624529f0f775abf4cd8457445931de74053dec5bbab49de873b done
|
|
#14 exporting config sha256:d6557e51b469086507b892558ee5960f31b77943d8c8fddc381e955e4eb3718a done
|
|
#14 naming to docker.io/library/mtusi-messenger:lab3 done
|
|
#14 unpacking to docker.io/library/mtusi-messenger:lab3 0.0s done
|
|
#14 DONE 0.1s
|
|
|
|
#15 [migrate] resolving provenance for metadata file
|
|
#15 DONE 0.0s
|
|
|
|
#16 [api] resolving provenance for metadata file
|
|
#16 DONE 0.0s
|
|
mtusi-messenger:lab3 Built
|
|
mtusi-messenger:lab3 Built
|
|
Network lab3-clean_backend Creating
|
|
Network lab3-clean_backend Created
|
|
Network lab3-clean_edge Creating
|
|
Network lab3-clean_edge Created
|
|
Volume lab3-clean_postgres_data Creating
|
|
Volume lab3-clean_postgres_data Created
|
|
Container lab3-clean-valkey-1 Creating
|
|
Container lab3-clean-postgres-1 Creating
|
|
Container lab3-clean-valkey-1 Created
|
|
Container lab3-clean-postgres-1 Created
|
|
Container lab3-clean-migrate-1 Creating
|
|
Container lab3-clean-migrate-1 Created
|
|
Container lab3-clean-api-2 Creating
|
|
Container lab3-clean-api-1 Creating
|
|
Container lab3-clean-api-2 Created
|
|
Container lab3-clean-api-1 Created
|
|
Container lab3-clean-nginx-1 Creating
|
|
Container lab3-clean-nginx-1 Created
|
|
Container lab3-clean-valkey-1 Starting
|
|
Container lab3-clean-postgres-1 Starting
|
|
Container lab3-clean-postgres-1 Started
|
|
Container lab3-clean-postgres-1 Waiting
|
|
Container lab3-clean-valkey-1 Started
|
|
Container lab3-clean-postgres-1 Healthy
|
|
Container lab3-clean-migrate-1 Starting
|
|
Container lab3-clean-migrate-1 Started
|
|
Container lab3-clean-migrate-1 Waiting
|
|
Container lab3-clean-postgres-1 Waiting
|
|
Container lab3-clean-postgres-1 Healthy
|
|
Container lab3-clean-migrate-1 Exited
|
|
Container lab3-clean-api-1 Starting
|
|
Container lab3-clean-api-1 Started
|
|
Container lab3-clean-api-2 Starting
|
|
Container lab3-clean-api-2 Started
|
|
Container lab3-clean-api-1 Waiting
|
|
Container lab3-clean-api-2 Waiting
|
|
Container lab3-clean-api-1 Healthy
|
|
Container lab3-clean-api-2 Healthy
|
|
Container lab3-clean-nginx-1 Starting
|
|
Container lab3-clean-nginx-1 Started
|
|
Container lab3-clean-postgres-1 Waiting
|
|
Container lab3-clean-valkey-1 Waiting
|
|
Container lab3-clean-nginx-1 Waiting
|
|
Container lab3-clean-api-1 Waiting
|
|
Container lab3-clean-api-2 Waiting
|
|
Container lab3-clean-migrate-1 Waiting
|
|
Container lab3-clean-valkey-1 Healthy
|
|
Container lab3-clean-postgres-1 Healthy
|
|
Container lab3-clean-migrate-1 Exited
|
|
Container lab3-clean-api-1 Healthy
|
|
Container lab3-clean-api-2 Healthy
|
|
Container lab3-clean-nginx-1 Healthy
|
|
$ make check test BASE_URL=http://localhost:18080
|
|
python3 scripts/check_contract.py
|
|
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
|
|
python3 tests/smoke.py --base-url "http://localhost:18080"
|
|
PASS: lab3 public API scenario; infrastructure and grading evidence remain separate.
|
|
$ make test-failover ACTION_SCRIPT=scripts/stop-one.sh BASE_URL=http://localhost:18080
|
|
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:18080"
|
|
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
|
{"observed_instances_before": 2, "successful_writes": 131, "failed_attempts": 0, "first_recovery_seconds": 2.118}
|
|
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
|
$ make instances
|
|
./scripts/instances.sh
|
|
CONTAINER STATE INSTANCE PID REVISION
|
|
lab3-clean-api-1 exited/unhealthy - 0 dev
|
|
lab3-clean-api-2 running/healthy 4a226e142873 83992 dev
|
|
$ make restore
|
|
./scripts/restore.sh
|
|
Container lab3-clean-api-2 Running
|
|
Container lab3-clean-api-1 Starting
|
|
Container lab3-clean-api-1 Started
|
|
Container lab3-clean-api-1 Waiting
|
|
Container lab3-clean-api-2 Waiting
|
|
Container lab3-clean-api-1 Healthy
|
|
Container lab3-clean-api-2 Healthy
|
|
$ make test-persistence ACTION_SCRIPT=scripts/restart.sh BASE_URL=http://localhost:18080
|
|
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.sh" --base-url "http://localhost:18080"
|
|
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
|
|
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
|
|
$ docker compose ps -a
|
|
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
|
|
lab3-clean-api-1 mtusi-messenger:lab3 "python src/gateway.…" api 43 seconds ago Up 6 seconds (healthy) 8080/tcp
|
|
lab3-clean-api-2 mtusi-messenger:lab3 "python src/gateway.…" api 43 seconds ago Up 6 seconds (healthy) 8080/tcp
|
|
lab3-clean-migrate-1 mtusi-messenger:lab3 "python src/migrate.…" migrate 43 seconds ago Exited (0) 35 seconds ago
|
|
lab3-clean-nginx-1 nginx:1.28.0-alpine3.21 "/docker-entrypoint.…" nginx 43 seconds ago Up 5 seconds (healthy) 127.0.0.1:18080->8080/tcp, 127.0.0.1:18081->8081/tcp
|
|
lab3-clean-postgres-1 postgres:18.2-alpine3.22 "docker-entrypoint.s…" postgres 44 seconds ago Up 8 seconds (healthy) 5432/tcp
|
|
lab3-clean-valkey-1 valkey/valkey:8.1.4-alpine3.22 "docker-entrypoint.s…" valkey 44 seconds ago Up 8 seconds (healthy) 6379/tcp
|
|
$ docker compose --profile expiry down -v
|
|
Container lab3-clean-nginx-1 Stopping
|
|
Container lab3-clean-nginx-1 Stopped
|
|
Container lab3-clean-nginx-1 Removing
|
|
Container lab3-clean-nginx-1 Removed
|
|
Container lab3-clean-api-2 Stopping
|
|
Container lab3-clean-api-1 Stopping
|
|
Container lab3-clean-api-1 Stopped
|
|
Container lab3-clean-api-1 Removing
|
|
Container lab3-clean-api-1 Removed
|
|
Container lab3-clean-api-2 Stopped
|
|
Container lab3-clean-api-2 Removing
|
|
Container lab3-clean-api-2 Removed
|
|
Container lab3-clean-valkey-1 Stopping
|
|
Container lab3-clean-migrate-1 Stopping
|
|
Container lab3-clean-migrate-1 Stopped
|
|
Container lab3-clean-migrate-1 Removing
|
|
Container lab3-clean-migrate-1 Removed
|
|
Container lab3-clean-postgres-1 Stopping
|
|
Container lab3-clean-postgres-1 Stopped
|
|
Container lab3-clean-postgres-1 Removing
|
|
Container lab3-clean-postgres-1 Removed
|
|
Container lab3-clean-valkey-1 Stopped
|
|
Container lab3-clean-valkey-1 Removing
|
|
Container lab3-clean-valkey-1 Removed
|
|
Volume lab3-clean_postgres_data Removing
|
|
Network lab3-clean_edge Removing
|
|
Network lab3-clean_backend Removing
|
|
Volume lab3-clean_postgres_data Removed
|
|
Network lab3-clean_edge Removed
|
|
Network lab3-clean_backend Removed
|