feat(deploy): fase 6 — Dockerfile para Coolify, PWA y guía de despliegue

- Dockerfile: python:3.12-slim + uv --frozen, no root, HEALTHCHECK sobre
  /api/health, un worker con --proxy-headers para el Traefik de Coolify
- HEAD explícito en /api/health y /api/export (curl -I del criterio 12;
  export HEAD devuelve el Content-Length exacto sin generar audio)
- PWA: manifest, iconos generados con numpy+stdlib, apple-touch-icon
- docker-compose.dev.yml (solo local), .dockerignore
- deploy/coolify.md: recurso, deploy key, webhook Gitea, dominio, volumen
- versión 0.2.0 · smoke test del contenedor en local: healthy
This commit is contained in:
Jorem Juárez committed 2026-08-30 08:08:45 -06:00
1 parent 1a6977a59e
commit fc506ac7c6
16 files changed
+288 -24

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
"""Genera los iconos PWA (PNG) sin dependencias más allá de numpy.
Uso: uv run --project backend python scripts/generar_iconos.py
"""
import struct
import zlib
from pathlib import Path
import numpy as np
DIR_ICONS = Path(__file__).resolve().parents[1] / "web" / "icons"
def escribir_png(ruta: Path, rgb: np.ndarray) -> None:
"""Escribe un PNG RGB 8-bit (sin filtros) usando solo stdlib."""
alto, ancho, _ = rgb.shape
def chunk(tipo: bytes, datos: bytes) -> bytes:
cuerpo = tipo + datos
return struct.pack(">I", len(datos)) + cuerpo + struct.pack(">I", zlib.crc32(cuerpo))
filas = b"".join(b"\x00" + rgb[y].tobytes() for y in range(alto))
ruta.write_bytes(
b"\x89PNG\r\n\x1a\n"
+ chunk(b"IHDR", struct.pack(">IIBBBBB", ancho, alto, 8, 2, 0, 0, 0))
+ chunk(b"IDAT", zlib.compress(filas, 9))
+ chunk(b"IEND", b"")
)
def icono(n: int) -> np.ndarray:
"""Dos anillos entrelazados (L teal, R ámbar) sobre fondo oscuro."""
y, x = np.mgrid[0:n, 0:n] / n
img = np.zeros((n, n, 3))
img[:] = np.array([13, 17, 23]) / 255 # --fondo
def anillo(cx: float, cy: float, r: float, grosor: float, color: tuple) -> np.ndarray:
d = np.hypot(x - cx, y - cy)
return np.exp(-(((d - r) / grosor) ** 2))[..., None] * (np.array(color) / 255)
img += anillo(0.40, 0.5, 0.24, 0.02, (88, 196, 220)) # oído izquierdo · alpha
img += anillo(0.60, 0.5, 0.24, 0.02, (240, 168, 60)) # oído derecho · beta
d_centro = np.hypot(x - 0.5, y - 0.5)
img += (np.exp(-((d_centro / 0.09) ** 2)) * 0.30)[..., None] # batido al centro
return (np.clip(img, 0, 1) * 255).astype(np.uint8)
if __name__ == "__main__":
DIR_ICONS.mkdir(parents=True, exist_ok=True)
for lado in (512, 192, 180):
escribir_png(DIR_ICONS / f"icono-{lado}.png", icono(lado))
print(f"icono-{lado}.png")