Bring the application, own tests, Dockerfile, toolchain, compose stack,
HAProxy, k6 and RustFS configuration, migrations, hooks, evidence and
scenario scripts and the CI job from the lab 4 solution commit d2744bc,
merge the lab 4 Makefile targets into the lab 5 skeleton Makefile
without touching its targets, and append the lab 4 solution variables
to the skeleton .env.example. The package and the application follow
the contract version 1.5.0, and the image and the throwaway test
containers are tagged lab5 so they do not collide with a lab 4 stand on
the same host.
This is the starting point of the lab 5 cycle: lint, own tests and the
offline skeleton check pass before any lab 5 change.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
50 lines
3.4 KiB
Bash
Executable File
50 lines
3.4 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
base=${1:-http://$(docker compose port lb 8080)}
|
|
stats=http://$(docker compose port lb 8404)/stats\;csv
|
|
header() { echo "date: $(date -u +%FT%TZ) commit: $(git rev-parse --short HEAD)"; }
|
|
{
|
|
header
|
|
echo "\$ docker compose --env-file .env config --quiet && echo valid"
|
|
docker compose --env-file .env config --quiet && echo valid
|
|
echo "\$ docker compose ps --format '{{.Service}} {{.Name}} {{.Status}} {{.Ports}}'"
|
|
docker compose ps --format '{{.Service}} {{.Name}} {{.Status}} {{.Ports}}'
|
|
echo "\$ docker compose config | grep -c container_name"
|
|
docker compose config | grep -c container_name || true
|
|
echo "\$ docker port <каждая реплика api> # реплики не публикуют порт"
|
|
for id in $(docker compose ps -q api); do echo "$(docker inspect -f '{{.Config.Hostname}}' "$id"): [$(docker port "$id")]"; done
|
|
echo "\$ docker inspect: hostname = X-Instance-Id, сети, лимиты CPU (nano) и памяти"
|
|
for id in $(docker compose ps -q); do
|
|
docker inspect -f '{{index .Config.Labels "com.docker.compose.service"}} {{.Config.Hostname}} {{.Name}} nets={{range $k, $v := .NetworkSettings.Networks}}{{$k}},{{end}} cpus={{.HostConfig.NanoCpus}} mem={{.HostConfig.Memory}} user={{.Config.User}} ro={{.HostConfig.ReadonlyRootfs}}' "$id"
|
|
done | sort
|
|
echo "\$ curl LB stats: backend api, server status check"
|
|
curl -fsS "$stats" | python3 -c 'import csv,sys
|
|
for r in csv.DictReader(sys.stdin.read().lstrip("# ").splitlines()):
|
|
if r["pxname"] == "api" and r["status"] != "MAINT (resolution)":
|
|
print(r["svname"], r["status"], r["check_status"], r["check_code"])'
|
|
echo "\$ for i in 1..6: curl -D - $base/health/live | X-Instance-Id"
|
|
for _ in 1 2 3 4 5 6; do curl -fsS -D - -o /dev/null "$base/health/live" | tr -d '\r' | grep -i '^x-instance-id'; done
|
|
} > evidence/stack.txt
|
|
{
|
|
header
|
|
echo "host: $(sysctl -n machdep.cpu.brand_string 2>/dev/null || uname -m), $(sysctl -n hw.ncpu 2>/dev/null) CPU, $(($(sysctl -n hw.memsize 2>/dev/null || echo 0) / 1073741824)) GiB RAM, $(sw_vers -productName 2>/dev/null) $(sw_vers -productVersion 2>/dev/null)"
|
|
echo "docker: $(docker version -f '{{.Server.Version}}'), VM: $(docker info -f '{{.NCPU}}') CPU, $(docker info -f '{{.MemTotal}}') bytes"
|
|
echo "compose: $(docker compose version --short)"
|
|
echo "images:"
|
|
grep -h -E 'image:|@sha256' compose.yaml Dockerfile | sed 's/^ */ /'
|
|
echo "python in image: $(docker exec "$(docker compose ps -q api | head -1)" python -V)"
|
|
echo "haproxy: $(docker compose exec -T lb haproxy -v | head -1)"
|
|
echo "rustfs: $(docker compose exec -T s3 rustfs --version 2>/dev/null | head -1)"
|
|
echo "packages (uv.lock):"
|
|
for name in fastapi uvicorn uvicorn-worker gunicorn asyncpg argon2-cffi pydantic pydantic-settings dishka structlog redis aiobotocore botocore aiohttp pillow; do
|
|
printf ' %s %s\n' "$name" "$(sed -n "/^name = \"$name\"$/{n;s/version = \"\(.*\)\"/\1/p;}" uv.lock)"
|
|
done
|
|
echo "process users (service uid command):"
|
|
for id in $(docker compose ps -q); do
|
|
service=$(docker inspect -f '{{index .Config.Labels "com.docker.compose.service"}}' "$id")
|
|
docker top "$id" -eo pid,uid,comm | awk -v s="$service" 'NR > 1 {print " " s, $2, $3}'
|
|
done | sort -u
|
|
} > evidence/environment.txt
|
|
cat evidence/stack.txt evidence/environment.txt
|