forked from mtusi2026/mtusi2026lab4
MinIO community images can no longer be pulled on this arm64 host, so the stand runs RustFS 1.0.4 pinned by digest as non-root with a read only root, no published port, the console off and data on the s3data volume. A one-off s3-init with rc v0.1.36 creates the bucket, keeps it private for anonymous clients, creates the API user with a policy on the objects and listing of that one bucket, imports a lifecycle rule for incomplete multipart uploads and checks itself; the API replicas start only after it succeeded. Root keys reach only s3, s3-init and the operator s3-cli; the API gets its own key and the S3 settings through an anchor merged into its environment. secrets.sh creates hex S3 keys, the restart hook restarts S3 next to PostgreSQL and Valkey and waits until it is healthy, the limits policy covers the S3 services, and the stack evidence lists the new packages. The object storage adapter is tested against a throwaway RustFS of the same image: a 10 MiB round trip, a missing object, an idempotent delete and an unreachable endpoint failing within the request budget. 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
|