Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
An instance can now be pointed at a model entirely from its environment — so a
container is redeployed with the Coach already working, and nobody has to open
an admin screen:
COACH_PROVIDER=compatible
COACH_BASE_URL=https://ai.example.com # WITHOUT /v1 — the adapter adds it
COACH_MODEL=vendor/model-name
COACH_API_KEY=sk-... # or the provider's own variable
Naming a provider is the whole configuration, so it also turns the Coach on: an
instance started this way that then reported itself "off" would be a puzzle with
no clue in it.
Three decisions worth stating:
- The environment is the *base*, the way DEFAULTS is, and the saved file is
layered on top: an admin who picked a provider in the app meant it, and this
only fills what is absent.
- The key is deliberately NOT a field of the config. That object is cached,
written to data/coach.json by any admin action, and included in the backup the
docs tell people to make. envCredentialFor reads it from the process
environment instead, so it is written nowhere and never surfaced by any route
that reports configuration. A pasted credential still outranks it, and a filed
one that fails to decrypt stays a failure rather than quietly falling back to
a key nobody knows is being spent.
- What the environment supplies is stripped before the file is written. A saved
config used to be written back whole, which would have frozen this start-up's
values on disk — and since the file outranks the environment, a later change
to COACH_MODEL would have been silently ignored.
Verified through the server's own path (config → credentialFor → jobEnv →
adapter) against the OpenAI-compatible router this fork runs on: a chest+triceps
request came back as a six-exercise routine with the cardio row first and
correctly marked `mode: cardio`.
206 lines
11 KiB
Bash
206 lines
11 KiB
Bash
# Copy this file to ".env" and adjust for your setup, then: docker compose up -d
|
|
#
|
|
# ── Local testing (default) ────────────────────────────────────────────────
|
|
# Works out of the box on the machine running Docker. Open http://localhost:8080
|
|
RP_ID=localhost
|
|
ORIGIN=http://localhost:8080
|
|
WEB_PORT=8080
|
|
RP_NAME=KuentaGYM
|
|
|
|
# ── Real deployment behind your own HTTPS domain ───────────────────────────
|
|
# Passkeys are bound to the exact hostname, and browsers only allow them over
|
|
# HTTPS (localhost is the one exception). Put KuentaGYM behind a reverse proxy /
|
|
# tunnel that terminates TLS for your domain, then set:
|
|
#
|
|
# RP_ID=gym.example.com
|
|
# ORIGIN=https://gym.example.com
|
|
# WEB_PORT=8080
|
|
# RP_NAME=KuentaGYM
|
|
#
|
|
# (Point your proxy at the web container's WEB_PORT. See docs/SELF_HOSTING.md.)
|
|
|
|
# ── Admin dashboard & invite-only signup (optional) ────────────────────────
|
|
# Both off by default — a fresh instance has open signup and no admin.
|
|
#
|
|
# Make yourself an admin: register your own passkey profile first, find your
|
|
# user id in ./data/db.json ("users"[].id), then list it here (comma-separated
|
|
# for several admins). Admins get an "Admin dashboard" link in Settings to see
|
|
# users, disable accounts, generate invite codes and view workout history.
|
|
#
|
|
# ADMIN_UIDS=youruserid,anotheradmin
|
|
#
|
|
# Require an invite code to create new profiles (existing accounts keep working;
|
|
# generate the codes from the admin dashboard):
|
|
#
|
|
# INVITE_ONLY=1
|
|
#
|
|
# Remove the "Continue without account" button, so a profile is the only way in.
|
|
# Guest mode keeps everything in the browser and never touches this server, but
|
|
# on an instance meant for a known set of people it is still the wrong front
|
|
# door. Anyone already inside as a guest is signed out on their next visit; the
|
|
# data they made stays in that browser. Defaults to on (guests allowed):
|
|
#
|
|
# ALLOW_GUEST=0
|
|
|
|
# ── Activity log (optional) ────────────────────────────────────────────────
|
|
# The admin dashboard shows an activity log: who signed in, who tried and
|
|
# failed, and every admin action (disabling an account, creating or revoking an
|
|
# invite code). It lives in ./data/audit.log, one JSON object per line, so you
|
|
# can also just read it with `tail` or `jq`.
|
|
#
|
|
# It is ON by default. It records strictly less than this instance already
|
|
# holds — every profile is in db.json and every workout is in state-<uid>.json,
|
|
# both readable by any admin — and a log that ships switched off tells you
|
|
# nothing on the day you need it. Turn it off completely with:
|
|
#
|
|
# AUDIT_LOG=0
|
|
#
|
|
# Retention is a cap, not an archive. Whichever limit is reached first wins;
|
|
# set either to 0 to disable that limit:
|
|
#
|
|
# AUDIT_MAX=5000 # events kept
|
|
# AUDIT_DAYS=90 # days kept
|
|
#
|
|
# IP addresses are the one thing that is OFF unless you ask, because they are
|
|
# the only field here that says where somebody physically is. They are also the
|
|
# only way to tell one failed sign-in from twenty. Three settings:
|
|
#
|
|
# AUDIT_IP=off # default — no addresses at all
|
|
# AUDIT_IP=net # network only: 203.0.113.0/24, 2001:db8:1::/48
|
|
# AUDIT_IP=full # the whole address
|
|
#
|
|
# The address is read from CF-Connecting-IP, then the first entry of
|
|
# X-Forwarded-For, then X-Real-IP, and finally the connecting socket itself if
|
|
# none of those is present.
|
|
#
|
|
# A forwarded-for header is only worth anything if whatever sits in front
|
|
# OVERWRITES it instead of passing a client-supplied one through — otherwise a
|
|
# caller simply states the address it would like logged. The web container now
|
|
# overwrites X-Forwarded-For and X-Real-IP with the real peer, and DROPS
|
|
# CF-Connecting-IP, so the bundled stack records an address nobody can choose.
|
|
# (Before, X-Forwarded-For was appended to rather than replaced, and
|
|
# CF-Connecting-IP was passed straight through — both were forgeable.)
|
|
#
|
|
# Cloudflare is first in that list on purpose: a Cloudflare tunnel does not put
|
|
# the visitor in X-Forwarded-For at all, so that header would otherwise record
|
|
# the tunnel itself and look perfectly plausible. If — and only if — Cloudflare
|
|
# is genuinely in front of you, let its header through again:
|
|
#
|
|
# CF_CONNECTING_IP=$http_cf_connecting_ip
|
|
#
|
|
# That is safe there because Cloudflare sets the header itself, replacing
|
|
# anything the client sent. Anywhere else, leave it unset.
|
|
|
|
# ── Session length (optional) ──────────────────────────────────────────────
|
|
# How long a sign-in lasts, in days. Default 90 — long enough that people who
|
|
# train regularly never see a login screen, short enough that a stolen cookie
|
|
# doesn't stay good forever. Lower it for an instance on the open internet,
|
|
# raise it for a private one. Only affects new sign-ins; cookies already handed
|
|
# out keep the lifetime they were issued with. Users can end every session on
|
|
# every device themselves with "Sign out everywhere" in Settings.
|
|
#
|
|
# SESSION_DAYS=90
|
|
|
|
# ── Fitting into an existing stack (optional) ──────────────────────────────
|
|
# The defaults assume KuentaGYM is on its own: an API service called `api` on
|
|
# port 3000, and nginx listening on 80 inside the web container. If you are
|
|
# merging this into a compose file that already has an `api`, or you front the
|
|
# web container with your own reverse proxy, move them here. The web image
|
|
# renders its nginx config at start-up, so these apply to a prebuilt image and
|
|
# need no rebuild. BACKEND and PORT together are what /api is proxied to, so
|
|
# they must name a service the web container can reach on your network:
|
|
#
|
|
# NGINX_PORT=80
|
|
# BACKEND=api
|
|
# PORT=3000
|
|
#
|
|
# Serving KuentaGYM under a subpath (https://example.com/gym/)? If your reverse
|
|
# proxy strips the prefix before the container sees it, set nothing — the app
|
|
# asks its own address for the API. If it passes the prefix through, name it
|
|
# here without a trailing slash:
|
|
#
|
|
# BASE_PATH=/gym
|
|
|
|
# ── Notifications (optional) ───────────────────────────────────────────────
|
|
# Push works out of the box — nothing to set. VAPID keys are generated on first
|
|
# run and saved to ./data/vapid.json. Each user's browser reports its own
|
|
# timezone automatically, so the workout-day reminder fires at their local
|
|
# time regardless of where the server runs or where they're travelling.
|
|
#
|
|
# Push services want a contact address for whoever operates the server, in case
|
|
# they need to get in touch about your pushes. Defaults to your ORIGIN, which is
|
|
# fine; set a mailto: if you would rather they mailed you:
|
|
#
|
|
# VAPID_SUBJECT=mailto:you@example.com
|
|
|
|
# ── AI Coach (optional, off by default) ────────────────────────────────────
|
|
# The Coach stays off until an admin turns it on in Settings → Admin and
|
|
# connects a provider. An instance that never does is byte-for-byte the same
|
|
# app it was before the feature existed.
|
|
#
|
|
# Anthropic, OpenAI, Gemini and any OpenAI-compatible endpoint (Ollama, LM
|
|
# Studio, vLLM, OpenRouter…) are driven over plain HTTPS with an API key and
|
|
# need nothing that is not already in the default image. Nothing to set here.
|
|
#
|
|
# API_TARGET only matters if you want the Claude Agent SDK or the Codex CLI
|
|
# running inside the container. `default` carries no AI runtime at all — no
|
|
# Agent SDK, no Codex, no bubblewrap. `coach` adds them (~300 MB):
|
|
#
|
|
# API_TARGET=coach docker compose up -d --build api
|
|
#
|
|
# COACH_DISABLED is the kill switch that outranks the admin toggle. Set it when
|
|
# you want the Coach off for certain — after an incident, or on an instance
|
|
# where nobody should be able to turn it on:
|
|
#
|
|
# COACH_DISABLED=1
|
|
#
|
|
# COACH_JOB_TIMEOUT_MS gives a job longer than the default five minutes. Only a
|
|
# local model on a CPU needs it — and normally only for the first request after
|
|
# the model server restarts (the api pre-warms the rules cache after that; a
|
|
# warm review on a 3B model takes one to a few minutes, depending on the CPU).
|
|
# A hosted API that needs
|
|
# more has a problem. Never goes below one minute.
|
|
#
|
|
# COACH_JOB_TIMEOUT_MS=1500000
|
|
#
|
|
# ── Configuring the Coach from the environment ─────────────────────────────
|
|
# Optional, and the alternative to the admin screen: an instance can be given
|
|
# its provider at start-up, so a container is redeployed with the Coach already
|
|
# pointed at a model and nobody has to open Settings → AI Coach. Naming a
|
|
# provider here is the whole configuration — it also turns the Coach on — and
|
|
# anything chosen later in the app wins over it.
|
|
#
|
|
# COACH_PROVIDER=compatible
|
|
# COACH_BASE_URL=https://ai.example.com
|
|
# COACH_MODEL=vendor/model-name
|
|
# COACH_API_KEY=sk-...
|
|
#
|
|
# COACH_BASE_URL is the endpoint WITHOUT the /v1 suffix: the adapter appends
|
|
# /v1/chat/completions itself, which is why the built-in OpenAI default is
|
|
# https://api.openai.com and not .../v1. Getting this wrong looks like a
|
|
# mysterious "unexpected response shape" in the job log rather than a 404.
|
|
#
|
|
# COACH_API_KEY may be omitted in favour of the variable the provider itself
|
|
# declares — OPENAI_COMPAT_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY,
|
|
# ANTHROPIC_API_KEY — which is also the name the key is passed under when the
|
|
# request is made.
|
|
#
|
|
# A provider chosen in the app (or a key pasted there) outranks these: the
|
|
# environment configures an instance nobody has set up in the UI, and never
|
|
# overrides a choice someone made in one. What the environment supplies is
|
|
# deliberately NOT written back into ./data/coach.json, so changing a variable
|
|
# and redeploying always takes effect.
|
|
#
|
|
# Credentials never live in the config file. The ones pasted in the app are
|
|
# encrypted into ./data/coach.json, one per provider, or for the Codex provider
|
|
# cached in ./coach-auth — a sibling of ./data, never inside it, so a live
|
|
# sign-in does not ride along in the documented backup archive. A key set here
|
|
# is read from the environment at request time and written nowhere.
|
|
# See docs/AI_COACH.md.
|
|
# ── Hevy map regeneration (developers only) ────────────────────────────────
|
|
# Not used by the running app. End users paste their own key in Settings →
|
|
# Import from Hevy. Set this only to regenerate frontend/src/lib/hevy-id-map.js:
|
|
#
|
|
# HEVY_API_KEY=
|
|
# node scripts/build-hevy-id-map.mjs
|