Recover InBraille from the production image (1.3.1) and move it to Gitea
Release / Plano (reaproveitar a imagem?) (push) Successful in 8s
CI / Trivy (dependências, segredos e configuração) (push) Failing after 8s
Release / ci (push) Failing after 9s
CI / Testes e imagem Docker (linux/arm64) (push) Skipped
Release / Publica a imagem (linux/arm64) (push) Skipped
Release / Cria a release no Gitea (push) Skipped

The GitHub account was suspended and the repository had no backup. The deployed code
(src/, public/, index.html, main.py, requirements.txt) was extracted from the production
image 1.3.1. The tests, Dockerfile, compose files, SECURITY.md, CHANGELOG.md and README were
rebuilt from the records of the work sessions that created them; LICENSE, .gitignore,
robots.txt and sitemap.xml were recreated. CI now runs on Gitea Actions.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Sonnet 5.5 committed 2026-11-02 00:15:01 -03:00
commit a9aec5abe4
74 files changed
+5178

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Uso: scripts/plano-imagem.sh <registro> <repositório>
# Imprime inputs=, image= e reuse= (para $GITHUB_OUTPUT). O hash cobre só os
# arquivos que entram no build da imagem, não a documentação nem a configuração
# de ferramentas. reuse=true quando o registro já tem inputs-<hash>.
set -euo pipefail
registry=$1; ns=${2,,}
inputs=$(git ls-tree -r HEAD \
| awk -F' ' '$2 !~ /^(\.gitea|\.github|\.claude|\.wolf|docs)\// && $2 !~ /^(README.*|CHANGELOG\.md|SECURITY\.md|LICENSE|\.gitignore|\.gitattributes|docker-compose.*\.yaml|scripts\/release-notes\.sh)$/' \
| sha256sum | cut -c1-16)
token=$(curl -fsS "https://$registry/v2/token?service=container_registry&scope=repository:$ns:pull" | jq -r .token)
code=$(curl -s -o /dev/null -w '%{http_code}' -I \
-H "Authorization: Bearer $token" \
-H 'Accept: application/vnd.oci.image.index.v1+json,application/vnd.docker.distribution.manifest.list.v2+json,application/vnd.oci.image.manifest.v1+json' \
"https://$registry/v2/$ns/manifests/inputs-$inputs")
echo "inputs-$inputs -> HTTP $code" >&2
reuse=false; [ "$code" = 200 ] && reuse=true
echo "inputs=$inputs"
echo "image=$registry/$ns"
echo "reuse=$reuse"
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
# Imprime as notas de uma release: a imagem publicada (quando houver) e a seção
# do CHANGELOG.md daquela versão (ou o log de commits desde a tag anterior, se
# não houver seção).
#
# scripts/release-notes.sh v1.2.3 [git.exemplo.com/dono/projeto]
set -euo pipefail
tag=${1:?uso: release-notes.sh <tag> [imagem]}
image=${2:-}
version=${tag#v}
if [ -n "$image" ]; then
echo "## Imagem"
echo
echo '```'
echo "$image:$version"
echo '```'
echo
fi
section=""
if [ -f CHANGELOG.md ]; then
section=$(awk -v head="## [$version]" '
index($0, head) == 1 { found = 1; next }
found && /^## \[/ { exit }
found && /^\[[^]]+\]: / { next }
found { print }
' CHANGELOG.md)
fi
if [ -n "$(printf '%s' "$section" | tr -d '[:space:]')" ]; then
printf '%s\n' "$section"
else
previous=$(git describe --tags --abbrev=0 "$tag^" 2>/dev/null || true)
echo "## Mudanças${previous:+ desde $previous}"
echo
git log --no-merges --format='- %s (%h)' "${previous:+$previous..}$tag"
fi
+76
View File
@@ -0,0 +1,76 @@
#!/usr/bin/env bash
# Teste de fumaça da imagem do InBraille, do jeito que ela roda em produção
# (--read-only, sem capabilities, usuário sem privilégios): as páginas e os arquivos de
# SEO respondem, a API codifica, decodifica e GERA um STL de verdade (VTK e as bibliotecas
# gráficas da imagem), os cabeçalhos de segurança estão lá e nada interno vaza.
#
# scripts/smoke-imagem.sh <imagem>
#
# Cada falha é impressa e o script sai com 1 no fim, para mostrar tudo de uma vez.
set -uo pipefail
imagem=${1:?uso: smoke-imagem.sh <imagem>}
app=inbraille-smoke-${GITHUB_RUN_ID:-$$}
falhas=0
falhou() { echo "FALHOU $1"; falhas=$((falhas + 1)); }
# Os daemons dos runners persistem entre jobs: limpa sempre, inclusive se falhar.
trap 'docker rm -f "$app" >/dev/null 2>&1' EXIT
docker run -d --name "$app" --read-only --tmpfs /tmp --cap-drop ALL \
--security-opt no-new-privileges:true "$imagem" >/dev/null || exit 1
ip=""
for _ in $(seq 1 40); do
ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$app" 2>/dev/null)
[ -n "$ip" ] && curl -fsS -o /dev/null "http://$ip:3000/" 2>/dev/null && break
sleep 1
done
base=http://$ip:3000
curl -fsS -o /dev/null "$base/" || { echo "FALHOU /: sem resposta"; docker logs "$app" | tail -20; exit 1; }
status() { [ "$(curl -s -o /dev/null -w '%{http_code}' "$base$2")" = "$1" ] || falhou "$2: esperado $1"; }
# Páginas (a mesma index.html atende os três idiomas) e arquivos de SEO.
status 200 /
status 200 /en
status 200 /zh
status 200 /robots.txt
status 200 /sitemap.xml
status 200 /google21a790a2c23c0ec5.html
status 200 /public/index.js
curl -s "$base/sitemap.xml" | python3 -c 'import sys,xml.dom.minidom as m; m.parseString(sys.stdin.read())' 2>/dev/null || falhou "/sitemap.xml: XML inválido"
curl -s "$base/robots.txt" | grep -qi '^sitemap:' || falhou "/robots.txt: sem a linha Sitemap"
# Nada interno vaza, e a documentação interativa da API fica desligada.
for p in /docs /openapi.json /main.py /src/config.py /public/../main.py /Dockerfile; do status 404 "$p"; done
# API: ida e volta do texto, e um STL pequeno de verdade.
enc=$(curl -s -X POST "$base/api/encode" -H 'Content-Type: application/json' -d '{"text":"ola","alphabet":"Brazilian"}')
printf %s "$enc" | grep -q '⠕' || falhou "/api/encode: resposta sem Braille ($enc)"
stl=$(mktemp); trap 'rm -f "$stl"; docker rm -f "$app" >/dev/null 2>&1' EXIT
code=$(curl -s -o "$stl" -w '%{http_code}' -X POST "$base/api/to-stl" -H 'Content-Type: application/json' -d '{"braille":"⠓⠑⠇⠇⠕","resolution":15}')
[ "$code" = 200 ] || falhou "/api/to-stl: esperado 200, veio $code"
# STL binário: 80 bytes de cabeçalho + 4 de contagem de triângulos + 50 bytes por triângulo.
python3 - "$stl" <<'PY' || falhou "/api/to-stl: o STL gerado é inválido"
import struct,sys,os
b=open(sys.argv[1],'rb').read()
n=struct.unpack('<I',b[80:84])[0]
sys.exit(0 if n>0 and len(b)==84+50*n else 1)
PY
# Limites: corpo grande demais é recusado.
[ "$(head -c 70000 /dev/zero | curl -s -o /dev/null -w '%{http_code}' -X POST "$base/api/encode" --data-binary @-)" = 413 ] || falhou "/api/encode: corpo de 70 KB deveria dar 413"
# Cabeçalhos de segurança.
head=$(curl -sI "$base/")
grep -qi "^content-security-policy:.*frame-ancestors 'none'" <<< "$head" || falhou "/: CSP sem frame-ancestors"
grep -qi '^x-content-type-options: nosniff' <<< "$head" || falhou "/: sem X-Content-Type-Options"
grep -qi '^x-frame-options: DENY' <<< "$head" || falhou "/: sem X-Frame-Options"
grep -qi '^cache-control: .*no-cache' <<< "$head" || falhou "/: sem Cache-Control no-cache (as páginas precisam revalidar)"
# Roda sem privilégios.
[ "$(docker exec "$app" id -u)" = 10001 ] || falhou "o processo não roda como o usuário 10001"
[ "$falhas" = 0 ] && echo "ok: páginas, SEO, API (incl. STL), cabeçalhos e isolamento conferidos"
[ "$falhas" = 0 ]