main
11
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f36a32e8af |
Deploy path: pin the project name the instance already runs under
The file this deployment is pasted from had no `name:`, so the project name came from the directory Dokploy writes it in. It already runs as `kuentagym`, and the volumes are pinned by `name:` either way — this just stops a pasted copy from renaming the stack and the containers in every `docker` command and log line. |
||
|
|
cc257d2671 |
Deploy path: pasar las variables de supervisión, o no hay panel que supervisar
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
"¿Cómo superviso los usuarios que se han creado, los que están logueados y todo eso?" — no se podía, y la causa era de despliegue: `ADMIN_UIDS` es la ÚNICA forma de ser admin (nada en el código pone `user.admin`), y este compose lista el entorno variable por variable, así que llegaba al host y nunca al contenedor. Sin ella el servidor no ofrece `/api/admin/*`, `/api/me` responde `admin: false`, y la fila "Admin dashboard" no aparece en Ajustes: el panel existe y no hay puerta. Ahora el compose pasa las diez que faltaban: `ADMIN_UIDS`, `INVITE_ONLY`, `ALLOW_GUEST`, `SESSION_DAYS` (los interruptores de la instancia) y `AUDIT_LOG`, `AUDIT_MAX`, `AUDIT_DAYS`, `AUDIT_IP` (los límites del registro de actividad), más `VAPID_SUBJECT` y `REMINDER_TICK_MS`. Con los `:-` de siempre: una instancia que no las ponga queda exactamente como estaba. `docs/SELF_HOSTING.md` dice ahora, en el paso donde se habla de `ADMIN_UIDS`, que es la única puerta de entrada al panel y cómo leer los ids de una instancia que ya corre (un `node -e` sobre db.json dentro del contenedor, sin instalar nada). |
||
|
|
52d1a05426 |
Deploy path: pass OPENCODE_API_KEY through, not only JEV_API_KEY
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
The gateway hands you a variable called OPENCODE_API_KEY, and the compose lists the environment explicitly — a variable that is not named there reaches Dokploy and never reaches the container. Pasting the key under the name the console gave it would have left the second opinion reading as unconfigured, which is exactly the shape of bug that looks like the feature is broken rather than unconfigured. |
||
|
|
90aa802980 |
La segunda opinión: un juicio sobre tus números, con la probabilidad que trae
Tests / test (push) Canceled after 0s
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
Preguntaste si se podía implementar Jev, y con qué API. Resulta que Jev se sirve por OpenCode Zen,
así que una sola cuenta cubre esto y cualquier otra cosa apuntada a ese gateway:
POST https://opencode.ai/zen/v1/systemone Bearer <clave> model: jev-1.13
Y ahí está la razón de que valga la pena: Jev no es un modelo de chat. Le mandás un *estado* y
preguntas tipadas — sí/no (`noul`), opción (`choice`), rúbrica (`score`) — y contesta todas en una
sola petición con el valor **y la probabilidad que le puso**. "62% probable" se puede discutir;
"tomate una semana de descarga" no. Así que no entra por el Coach (que necesita *escribir*) y no se
fuerza dentro de su lista de proveedores: tiene su módulo, sus dos rutas y su tarjeta.
Qué hace. En Salud, arriba de la grilla, una tarjeta con cuatro respuestas: qué tan listo estás para
entrenar fuerte (nivel 1-5, con el número al lado), si la semana pide bajar carga (62% probable), qué
parte del cuerpo parece menos recuperada, y qué métrica de salud merece atención — esa última con la
última lectura de la métrica que nombró, para que "vigilá tu frecuencia en reposo" venga con el 62
que lo motivó. La hoja detrás del ⓘ dice a dónde va y exactamente qué se envía, con el mismo resumen
que devuelve el servidor.
Lo que sale, y lo que no. Se decide en `api/jev.js` y son agregados: una semana de cada métrica por
campo como la escribió el teléfono, series por parte del cuerpo de 4 semanas y de la última, sesiones,
días desde la última, RPE medio, estancamientos *por nombre de ejercicio*, el último pesaje y su
cambio. Ningún identificador: ni perfil, ni nombre, ni títulos de entrenamientos, ni ids de
ejercicios, ni chat — hay un test que lo afirma sobre el JSON, porque es una promesa que hacen los
docs y nada más la miraba. La única excepción es deliberada y está documentada: la nota de
*limitaciones* del cuestionario del Coach, porque "hombro malo" cambia la respuesta. (Los títulos sí
estuvieron un rato ahí: los saqué al escribir ese test, y el test se quedó.)
Un juicio no es una instrucción, y el código lo trata así. Cada respuesta se muestra con su
probabilidad; una pregunta que el modelo no contestó se muestra como no contestada, nunca como un
cero; un nivel que no habíamos ofrecido se marca en vez de disfrazarse de propio; y si los datos
cambiaron desde que se pidió (una sesión registrada, una noche que llegó) la tarjeta lo dice en lugar
de seguir pareciendo actual. Tampoco corre por temporizador: cuesta una petición, así que pasa cuando
alguien aprieta *Preguntar*, con cupo por perfil y por día y un piso de diez minutos aplicados en el
servidor, no en la pantalla.
El Coach, además, lo recibe como `secondOpinion` en su payload **solo si tiene menos de seis horas**,
como evidencia con confianza adjunta para citar en `why`, nunca como una orden ni como un cambio de
plan. Es la mitad que faltaba de "y el Coach escribe con eso".
El lector de respuestas es tolerante a propósito: el contrato de la petición está documentado, la
respuesta no la vimos nunca del servicio real, así que acepta las formas plausibles
(`answers`/`results`, `option`/`answer`/`choice`, `probability` o una distribución sobre los niveles),
normaliza lo que encuentra y devuelve `null` por lo que no puede leer. El cuerpo crudo queda guardado
al lado del parseado (y sale con `?raw=1`): la primera llamada real se puede mirar, y una forma mal
adivinada es un arreglo, no un misterio.
Dos cosas que encontré escribiendo esto y que quedan arregladas: una variable de entorno vacía se
leía como **cero** (`Number('')` pasa un chequeo ingenuo), así que un cupo sin configurar era "cero
peticiones" — un feature que parece configurado y no funciona nunca; y agregar la palabra *Back*
para la espalda redefinió el botón *Atrás* de la app a "Espalda", porque en un objeto literal la
última clave gana y nada lo dice. El catálogo de español tiene ahora un test que falla si una clave
se escribe dos veces, mutación comprobada.
Cobertura: 11 tests del módulo (el estado, las preguntas, cada forma de respuesta, la promesa de
privacidad, el cupo), 5 de las rutas contra un gateway de mentira y el servidor real, 6 del modelo de
vista en el frontend y 5 de render por la tarjeta real. API 259 en verde, frontend 1696, build OK.
|
||
|
|
4222e8d86b |
Deploy path: X-Forwarded-For is the append form here, not $remote_addr
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
I changed this to $remote_addr when the resolver fix went in, on the reasoning that appending lets a client put its own address in front of the real one. That reasoning is right for web/nginx.conf.template and wrong here, and the deployment's own access log shows why: this nginx is NOT the edge. Traefik terminates TLS in front of it, logs the web container's peer as 10.0.1.182, and carries the real client (66.98.33.30) in the header it sends. $remote_addr therefore records Traefik's own address, and $proxy_add_x_forwarded_for — which puts the incoming header first — is what preserves the person's. The API reads the first entry, so the append form is the correct one in this shape. Comment 4 now spells out both directions: append here because a trusted proxy is in front, $remote_addr in the registry template because there the container answers the internet directly, where an incoming header is exactly what cannot be trusted. Nothing recorded was wrong in the meantime — AUDIT_IP is off unless an operator asks for it — but this is the setting to get right before anybody turns it on. |
||
|
|
002e5e6bbb |
Deploy path: the header counts the traps it documents (there are four now)
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
|
||
|
|
7271dadbee |
The deploy path's nginx: re-resolve the api on every request
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
A plain `proxy_pass http://api:3000` is resolved once, when nginx starts, and the address stays pinned for the life of the container. Recreate the api — a deploy that changes its configuration, a --force-recreate, any restart that hands it a new IP — and the web container keeps talking to a dead address: every /api call answers 502, including /api/config, so the app cannot even boot. That is not hypothetical: it is what happened on gym.dploy.lol, where restarting the api to pick up new code produced 502 on every endpoint until the web container was restarted too. The generated config now asks Docker's embedded DNS again on every request instead: `resolver 127.0.0.11` plus `set $api_upstream http://api:3000` and `proxy_pass $api_upstream`. This is the same fix web/nginx.conf.template has carried for the registry-image shape (with a comment explaining issue #16), and comment 4 at the top of this file now records why the deploy path needs it too. Verified by rendering the command exactly as the container runs it and passing the result through an nginx config parser: both body limits in place, both locations on the variable, and the upstream still resolved through the embedded resolver. |
||
|
|
5eb0a5298a |
The deploy path's api container now keeps itself on the clone's revision
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
gym.dploy.lol runs deploy/compose-build-at-deploy.yml, and that stack has an asymmetry that has now cost two deploys: `web` serves the frontend build out of a shared volume, so every deploy refreshes the app by itself, while `api` copies the clone INTO its container at start-up. Compose recreates a service only when its configuration or image changed, and the clone is a volume, so neither does — the api kept running the previous revision while the frontend moved on. That is invisible from the outside except as a route that answers 404 although the screen that calls it is already deployed and visibly new, which is exactly what "Crear clave de ingesta → not found" was: POST /api/vitals/key hitting last week's server. The api's command is now a small loop instead of a one-liner: it syncs /app from the clone whenever the clone's revision changes, restarts the server on it, and starts it again if it ever exits (the old one-liner left that to the container restart policy, which also meant a full re-copy every time). Dependencies are reinstalled only when package.json itself changed, so a deploy costs a couple of seconds of downtime rather than a minute of npm install. It is careful about the window a deploy opens: `source` does `rm -rf /work/repo` before it re-clones, and the loop tests for api/server.js — a file a fresh clone writes and that rm removes — so a deploy caught mid-clone is waited out instead of half-copied. Two things this file has to get right, both verified rather than assumed. Every `$` in the container's script is written `$$`, because compose interpolates `$VAR` in block scalars too and an unescaped `$src` would have arrived empty (this is the same reason the web service writes `$$host`). And the loop's control flow was simulated before pushing: first start, a new clone, a package.json change, a server that dies, and a clone that disappears mid-deploy and comes back — five paths, all as intended. |
||
|
|
ba37ef8a44 |
Deploy path: give the health ingest 32 MB, and stop appending to X-Forwarded-For
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
gym.dploy.lol does not run docker-compose.yml. It runs deploy/compose-build-at-deploy.yml, where nginx is generated inline by the web service from a printf in its command, with a single global `client_max_body_size 5m`. The per-route 32 MB added for the Apple Health ingest lives in web/nginx.conf.template, which belongs to the registry-image path and is never read here — so a first export of more than 5 MB came back as nginx's own 413 HTML before the API saw a byte of it. That path now has a second location for /api/vitals/ingest with 32m; nginx picks the longest matching prefix, so that one route takes the bigger body and everything else keeps matching the API's MAX_BODY. Both limits are spelled out in comment 3 at the top, with a note that the two deployment shapes have to be changed together. Also fixes a smaller thing found while reading it: X-Forwarded-For was $proxy_add_x_forwarded_for, which APPENDS to whatever the client sent, and the API reads the first entry — so a caller could choose the address recorded about it. It is now $remote_addr, which is what web/nginx.conf.template already does and for the same reason documented there. Audit IPs are off by default, so nothing was being recorded; this matters the day somebody sets AUDIT_IP=net. Comment 3 also now records the two things that make a deploy confusing rather than broken: the api service copies the clone into /app at container start, so an api that was not recreated keeps serving the previous revision while web-build serves the new frontend (exactly the 404-on-a-new-route symptom), and web resolves api's IP once at start-up, so recreating api without web leaves nginx pointing at a dead address and every /api call answering 502. |
||
|
|
40959de0a2 |
Forward the COACH_* variables to the api container in the deploy compose
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
The api service lists its environment explicitly, and that list is an allowlist:
a variable set in the host's .env reaches the container only when it is named
there. Everything else in the panel is used solely to substitute ${…} in the
compose file — which is how COACH_PROVIDER can sit in Dokploy looking applied
while the api never sees it, the Coach stays off, and no screen anywhere shows a
button. That is exactly what happened on this instance.
The `:-` defaults keep an instance that sets none of them byte-for-byte as it
was: an empty value reads as unset in coach/config.js.
|
||
|
|
1a48efdbcc |
Add deploy/compose-build-at-deploy.yml for hosts that build at deploy time
Tests / test (pull_request) Canceled after 0s
The instance at gym.dploy.lol runs a five-service stack that clones the source and builds it on every deploy, rather than pulling the images docker-compose.yml names. That shape has three requirements nothing in the repository stated, and getting any of them wrong costs a deploy: - web-build has to copy the whole repository and build from frontend/. The frontend imports the Coach's core from ../../../api/coach/core/, so a build stage holding only frontend/ fails with nine UNRESOLVED_IMPORT errors — the reason web/Dockerfile copies api/coach/core/ into its build stage. - The volume names have to be pinned with `name:`. Unpinned, a restyled stack silently creates empty volumes and the profiles and training history look gone. - nginx needs client_max_body_size. Its default request limit is 1 MB while the app PUTs the whole profile to /api/data and the API accepts 5 MB — the sync starts failing with a 413 the UI cannot explain once a history grows past 1 MB. web/nginx.conf.template already sets 5m; this matches it. The file is the shape that instance runs, with its volume names filled in. |