openGym: Open-Source-Release als Self-Hosting-App
Rebranding GymLog → openGym. Ein-Befehl-Self-Hosting via Docker Compose: web (nginx serviert App + Proxy /api → api, ein Origin für Passkeys), api (Node/WebAuthn), media-Service lädt Übungs-GIFs beim ersten Start automatisch. Passkey-Domain über .env konfigurierbar (RP_ID/ORIGIN/WEB_PORT/RP_NAME), Secure-Cookie nur bei HTTPS (http://localhost funktioniert). MIT-Lizenz, README fürs Self-Hosting, docs/SELF_HOSTING.md, CONTRIBUTING.md. Standalone-Stack Ende-zu-Ende getestet (Passkey-Register/-Login, Daten-Sync, User-Isolation über den Proxy auf http://localhost).
This commit is contained in:
1 parent
0a0f2a004f
commit
3333b4decd
15 files changed
+436
-71
No files matched your search
@@ -0,0 +1,20 @@
|
||||
# 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=openGym
|
||||
|
||||
# ── 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 openGym 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=openGym
|
||||
#
|
||||
# (Point your proxy at the web container's WEB_PORT. See docs/SELF_HOSTING.md.)
|
||||
+7
-2
@@ -1,8 +1,13 @@
|
||||
# Übungs-Medien (via scripts/fetch-media.sh aus hasaneyldrm/exercises-dataset)
|
||||
# Exercise media — fetched on first `docker compose up` (or via scripts/fetch-media.sh)
|
||||
app/img/
|
||||
app/gif/
|
||||
|
||||
node_modules/
|
||||
# Runtime data — users, passkeys, per-user state, session secret
|
||||
data/
|
||||
|
||||
# Local config
|
||||
.env
|
||||
|
||||
node_modules/
|
||||
*.log
|
||||
.DS_Store
|
||||
@@ -0,0 +1,48 @@
|
||||
# Contributing to openGym
|
||||
|
||||
Thanks for taking a look! openGym is intentionally small and dependency-light, and the goal is
|
||||
to keep it that way — easy to read, easy to self-host.
|
||||
|
||||
## Project layout
|
||||
|
||||
```
|
||||
app/ frontend — one static SPA (index.html, app.js, style.css, data.js). No build step.
|
||||
api/ backend — server.js (Node, no framework), one dependency (@simplewebauthn/server).
|
||||
web/ nginx config that serves app/ and proxies /api to the backend.
|
||||
docs/ self-hosting guide.
|
||||
```
|
||||
|
||||
## Running for development
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
docker compose up -d --build
|
||||
# edit files in app/ (no build needed — just reload) or api/ (docker compose restart api)
|
||||
```
|
||||
|
||||
Frontend changes are plain HTML/CSS/JS — edit and refresh. When you change `app/*.js|css`,
|
||||
bump the `?v=N` query in `index.html` and `sw.js` so clients and the service worker refetch.
|
||||
|
||||
## Guidelines
|
||||
|
||||
- **Keep it dependency-light.** New npm packages in `api/` are a hard sell; the frontend has none.
|
||||
- **No build step for the frontend.** Vanilla JS, please.
|
||||
- **Match the style.** Small functions, clear names, comments only where the "why" isn't obvious.
|
||||
- **Don't commit** the exercise media (`app/img`, `app/gif`) or `data/` — they're gitignored.
|
||||
- **Test the flow** you touched. There's a jsdom smoke test used during development; at minimum,
|
||||
click through the affected screens in a browser before opening a PR.
|
||||
|
||||
## Good first issues
|
||||
|
||||
- Additional starter plans (upper/lower, full-body, 5×5…)
|
||||
- More languages for the exercise instructions (the dataset ships several)
|
||||
- Importers from other trackers (Strong, Hevy CSV → openGym JSON)
|
||||
- Accessibility passes on the workout and chart screens
|
||||
|
||||
## Reporting bugs
|
||||
|
||||
Open an issue with: what you did, what you expected, what happened, and your browser/OS. If it's
|
||||
about login/passkeys, include your `RP_ID`/`ORIGIN` (not the `data/` contents) — most login
|
||||
issues are an origin mismatch.
|
||||
|
||||
By contributing you agree your work is licensed under the project's [MIT License](LICENSE).
|
||||
@@ -0,0 +1,27 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Duarte Santos
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
---
|
||||
|
||||
Exercise data, images and animations under app/img and app/gif are NOT part of
|
||||
this MIT grant. They are fetched at build time from the third-party dataset
|
||||
github.com/hasaneyldrm/exercises-dataset and remain under that project's terms.
|
||||
@@ -1,53 +1,109 @@
|
||||
# GymLog 🏋️
|
||||
<div align="center">
|
||||
|
||||
Persönlicher Gym- & Körpergewicht-Tracker als mobile-first Web-App (PWA) —
|
||||
mit Apple-Passkey-Login (Face ID) und eigenem Profil pro Person.
|
||||
# 🏋️ openGym
|
||||
|
||||
**Live:** https://gym.duarte-santos.ch
|
||||
**A self-hosted gym & body-weight tracker you actually own.**
|
||||
|
||||
Plan your week, run guided workouts, track every set and your body weight over time —
|
||||
on your phone, synced across devices, behind your own passkey login. No account on someone
|
||||
else's server, no subscription, no ads. Just `docker compose up`.
|
||||
|
||||
Mobile-first PWA · passkey (Face ID / fingerprint) login · works on iOS & Android · MIT licensed
|
||||
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## Why
|
||||
|
||||
Most workout apps lock your data behind a login on their servers, nag you to upgrade, or
|
||||
disappear when the startup does. openGym is the opposite: **it runs on your box, your data
|
||||
stays in a folder you control, and it's yours to fork.** It still feels modern — installable
|
||||
as a home-screen app, passkey sign-in, offline support, sync across your phone and laptop.
|
||||
|
||||
## Features
|
||||
|
||||
- **Dashboard** — Wochenübersicht, Today-Card, Körpergewicht-Kurve, Streak & Volumen-Tiles
|
||||
- **Trainingsplan** — Wochenplan (Wochentag → Routine) + Routine-Editor mit Übungs-Picker
|
||||
(1'324 Übungen mit Animationen, Suche + Muskelgruppen-Filter)
|
||||
- **Umplanen per Kalender** — einzelne Tage überschreiben (krank / verpasst / andere Session),
|
||||
ohne den Wochenplan zu ändern
|
||||
- **Workout-Flow** — Start erkennt den Wochentag und startet die heutige Session direkt.
|
||||
Vorher wird immer das Körpergewicht abgefragt. Sätze abhaken, Gewichte vom letzten Mal
|
||||
vorausgefüllt, Rest-Timer mit Beep, Progression-Hints, PR-Erkennung
|
||||
- **Gewichts-Tracking pro Übung** — am Ende jeder Übung wird das Arbeitsgewicht bestätigt;
|
||||
das höchste je eingegebene Gewicht ist beim nächsten Mal der Startwert
|
||||
- **Stats** — GitHub-Style Activity-Heatmap (12 Monate), Körpergewicht-Chart,
|
||||
Kraft-Progression pro Übung, komplette Historie
|
||||
- **Passkeys statt Passwörter** — WebAuthn mit Face ID / Touch ID, Profile synchronisieren
|
||||
über Geräte; Gast-Modus (nur lokal) möglich
|
||||
- **PWA** — „Zum Home-Bildschirm", offline-fähig (Service Worker)
|
||||
- **Dashboard** — week overview, today's workout, body-weight curve with a goal line, streak & volume tiles
|
||||
- **Weekly plan** — assign a routine to each weekday, plus a routine editor over a library of **1,324 exercises** (searchable, with animated demos)
|
||||
- **Reschedule any day** — sick, missed a session, or fewer gym days this week? Move a workout to another day without touching your weekly plan
|
||||
- **Guided workouts** — it knows what day it is and starts today's session; asks your body weight first, pre-fills your weights from last time, checks off sets, rest timer, PR detection, per-exercise weight tracking that auto-sets your next default
|
||||
- **Body-weight tracking** — interactive chart with month/kg axes, drag to read any day, set a target weight drawn right through the graph
|
||||
- **Activity heatmap** — a GitHub-style year view, shaded by time spent training
|
||||
- **Passkeys, not passwords** — WebAuthn login with Face ID / Touch ID / fingerprint; each profile keeps its own data, synced across devices
|
||||
- **Themes** — light/dark + 8 accent colors, saved to your profile
|
||||
- **Yours to keep** — one-tap JSON export/import, guest mode, no telemetry
|
||||
|
||||
## Struktur
|
||||
## Quick start (self-host)
|
||||
|
||||
```
|
||||
app/ Frontend — handgebaute Static-SPA, kein Build-Step (Vanilla JS, Hash-Routing)
|
||||
api/ Backend — Node 22, kein Framework, @simplewebauthn/server, JSON-File-Storage
|
||||
scripts/ fetch-media.sh lädt die Übungs-Bilder/GIFs (nicht im Repo, ~140 MB)
|
||||
```
|
||||
|
||||
## Übungs-Medien
|
||||
|
||||
Die Übungsdaten (`app/data.js`) und Medien stammen aus
|
||||
[hasaneyldrm/exercises-dataset](https://github.com/hasaneyldrm/exercises-dataset).
|
||||
Bilder/GIFs sind nicht eingecheckt — einmalig holen mit:
|
||||
You need [Docker](https://docs.docker.com/get-docker/) with Compose.
|
||||
|
||||
```bash
|
||||
./scripts/fetch-media.sh # füllt app/img/ (12 MB) und app/gif/ (126 MB)
|
||||
git clone https://github.com/DuarteSantos8/gym-app opengym
|
||||
cd opengym
|
||||
cp .env.example .env
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
## Betrieb
|
||||
Open **http://localhost:8080**, tap **Create profile**, and you're in. First launch downloads
|
||||
the exercise media (~140 MB) once; after that it's instant.
|
||||
|
||||
- `app/` wird von einem beliebigen Static-Server ausgeliefert (nginx); JS/CSS/HTML mit
|
||||
`no-cache`, `img/`+`gif/` lange cachen. Assets sind mit `?v=N` versioniert.
|
||||
- `api/` läuft als Container (siehe `api/Dockerfile`), Env: `RP_ID` (Domain), `ORIGIN`
|
||||
(https-Origin), `DATA_DIR` (Volume, default `/data`). Reverse-Proxy routet `/api/*`
|
||||
auf Port 3000 der API, alles andere auf die Static-Site — **gleiche Domain**, sonst
|
||||
funktionieren Passkeys nicht.
|
||||
- User/Credentials liegen in `DATA_DIR/db.json`, App-State pro User in
|
||||
`DATA_DIR/state-<uid>.json`, Session-Secret in `DATA_DIR/secret` → Volume sichern.
|
||||
> Want it reachable from your phone over the internet with passkeys? You'll need an HTTPS
|
||||
> domain — it's a two-line change in `.env`. See **[docs/SELF_HOSTING.md](docs/SELF_HOSTING.md)**.
|
||||
|
||||
## How it works
|
||||
|
||||
```
|
||||
┌─────────────┐ ┌──────────────────────────────┐
|
||||
│ Your phone │──HTTPS─▶│ web (nginx) │
|
||||
│ / laptop │ │ ├─ serves the app (static) │
|
||||
└─────────────┘ │ └─ proxies /api ──────────┐│
|
||||
└──────────────────────────────┘│
|
||||
▼
|
||||
┌──────────────────────────┐
|
||||
│ api (Node + WebAuthn) │
|
||||
│ └─ ./data (JSON files) │
|
||||
└──────────────────────────┘
|
||||
```
|
||||
|
||||
- **app/** — the frontend: a hand-built static SPA (vanilla JS, no build step, hash routing)
|
||||
- **api/** — the backend: Node with no framework, one dependency (`@simplewebauthn/server`), storing everything as plain JSON files under `./data`
|
||||
- **web/** — nginx that serves the app and proxies `/api` to the backend, so everything is on **one origin** (passkeys require this)
|
||||
|
||||
Everything is deliberately small and readable — the whole app is a few files you can audit in an afternoon.
|
||||
|
||||
## Your data
|
||||
|
||||
Lives in `./data` on your host:
|
||||
|
||||
- `db.json` — profiles + public passkey credentials
|
||||
- `state-<user>.json` — each user's plan, workouts, body weight, settings
|
||||
- `secret` — the key that signs session cookies
|
||||
|
||||
**Back up the `./data` folder** and you've backed up everything. Passkey private keys never
|
||||
touch the server — they stay in your phone's secure hardware / your password manager.
|
||||
|
||||
## Configuration
|
||||
|
||||
All via `.env` (see `.env.example`):
|
||||
|
||||
| Variable | What it is | Default |
|
||||
|------------|-----------------------------------------------|-------------------------|
|
||||
| `RP_ID` | Hostname passkeys are bound to | `localhost` |
|
||||
| `ORIGIN` | Full URL the app is served from | `http://localhost:8080` |
|
||||
| `WEB_PORT` | Host port for the web UI | `8080` |
|
||||
| `RP_NAME` | Name shown in the passkey prompt | `openGym` |
|
||||
|
||||
## Tech
|
||||
|
||||
Vanilla JS SPA · Node (no framework) · nginx · Docker Compose · WebAuthn ·
|
||||
exercise data from [hasaneyldrm/exercises-dataset](https://github.com/hasaneyldrm/exercises-dataset).
|
||||
No frontend build, no database server, no cloud dependencies.
|
||||
|
||||
## Contributing
|
||||
|
||||
Issues and PRs welcome — see [CONTRIBUTING.md](CONTRIBUTING.md). Good first issues:
|
||||
more starter plans, exercise-data languages, import from other trackers.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE). Exercise images/GIFs are fetched from the upstream dataset and keep their own terms.
|
||||
+8
-6
@@ -1,4 +1,4 @@
|
||||
/* gym-api — passkey (WebAuthn) auth + per-user state storage for GymLog
|
||||
/* opengym-api — passkey (WebAuthn) auth + per-user state storage for openGym
|
||||
No framework, JSON-file storage, signed session cookies. */
|
||||
import http from 'node:http';
|
||||
import crypto from 'node:crypto';
|
||||
@@ -11,11 +11,13 @@ import {
|
||||
|
||||
const PORT = +(process.env.PORT || 3000);
|
||||
const DATA = process.env.DATA_DIR || '/data';
|
||||
const RP_ID = process.env.RP_ID || 'gym.duarte-santos.ch';
|
||||
const ORIGIN = process.env.ORIGIN || 'https://gym.duarte-santos.ch';
|
||||
const RP_NAME = 'GymLog';
|
||||
const RP_ID = process.env.RP_ID || 'localhost';
|
||||
const ORIGIN = process.env.ORIGIN || 'http://localhost:8080';
|
||||
const RP_NAME = process.env.RP_NAME || 'openGym';
|
||||
const SESSION_DAYS = 365;
|
||||
const MAX_BODY = 5 * 1024 * 1024;
|
||||
// Secure cookies require HTTPS; over plain http://localhost the flag would drop the cookie
|
||||
const SECURE = /^https:/i.test(ORIGIN) ? ' Secure;' : '';
|
||||
|
||||
fs.mkdirSync(DATA, { recursive: true });
|
||||
|
||||
@@ -67,9 +69,9 @@ function readSession(req) {
|
||||
return db.users.find(u => u.id === uid) || null;
|
||||
}
|
||||
function sessionCookie(uid) {
|
||||
return `gymsid=${makeSession(uid)}; Path=/; Max-Age=${SESSION_DAYS * 86400}; HttpOnly; Secure; SameSite=Lax`;
|
||||
return `gymsid=${makeSession(uid)}; Path=/; Max-Age=${SESSION_DAYS * 86400}; HttpOnly;${SECURE} SameSite=Lax`;
|
||||
}
|
||||
const clearCookie = 'gymsid=; Path=/; Max-Age=0; HttpOnly; Secure; SameSite=Lax';
|
||||
const clearCookie = `gymsid=; Path=/; Max-Age=0; HttpOnly;${SECURE} SameSite=Lax`;
|
||||
|
||||
/* ---------- challenge store (in-memory, 5 min TTL) ---------- */
|
||||
const challenges = new Map(); // cid -> {challenge, name?, uid?, exp}
|
||||
|
||||
+7
-7
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
/* ============================================================
|
||||
GymLog — personal gym & body-weight tracker
|
||||
openGym — personal gym & body-weight tracker
|
||||
Static SPA, localStorage, exercise data from data.js (EXDB)
|
||||
============================================================ */
|
||||
|
||||
@@ -557,14 +557,14 @@ function viewLogin(app) {
|
||||
app.innerHTML = `
|
||||
<div class="narrow" style="display:flex;flex-direction:column;justify-content:center;min-height:78vh;text-align:center">
|
||||
<div style="font-size:4rem">🏋️</div>
|
||||
<h1 style="font-size:2.2rem;font-weight:800;letter-spacing:-.02em;margin:8px 0 4px">GymLog</h1>
|
||||
<h1 style="font-size:2.2rem;font-weight:800;letter-spacing:-.02em;margin:8px 0 4px">openGym</h1>
|
||||
<div class="muted" style="margin-bottom:34px">Your workouts. Your weights. Your profile.</div>
|
||||
${webauthnOK() ? `
|
||||
<button class="btn primary" id="lg-in">👤 Sign in with passkey</button>
|
||||
<div style="height:10px"></div>
|
||||
<button class="btn" id="lg-new">✨ Create new profile</button>
|
||||
<div style="height:10px"></div>` : `
|
||||
<div class="card small muted" style="text-align:left">This browser doesn't support passkeys — you can still use GymLog locally on this device.</div>`}
|
||||
<div class="card small muted" style="text-align:left">This browser doesn't support passkeys — you can still use openGym locally on this device.</div>`}
|
||||
<button class="btn ghost dim" id="lg-guest">Continue without account</button>
|
||||
<div class="dim small" style="margin-top:26px;line-height:1.5">Passkeys use ${BIO} — no passwords.<br>Each profile keeps its own plan, workouts & body weight.</div>
|
||||
</div>`;
|
||||
@@ -653,7 +653,7 @@ function viewHome(app) {
|
||||
|
||||
app.innerHTML = `
|
||||
<div class="hdr">
|
||||
<div><h1>${USER ? 'Hi ' + esc(USER.name) + ' 💪' : 'GymLog 🏋️'}</h1><div class="sub">${today.toLocaleDateString('en-GB', {weekday:'long', day:'numeric', month:'long'})}</div></div>
|
||||
<div><h1>${USER ? 'Hi ' + esc(USER.name) + ' 💪' : 'openGym 🏋️'}</h1><div class="sub">${today.toLocaleDateString('en-GB', {weekday:'long', day:'numeric', month:'long'})}</div></div>
|
||||
<button class="iconbtn" id="btn-settings">⚙️</button>
|
||||
</div>
|
||||
|
||||
@@ -1821,9 +1821,9 @@ function viewSettings(app) {
|
||||
|
||||
<div class="card">
|
||||
<h2>Tip</h2>
|
||||
<div class="small muted" style="line-height:1.5">📱 ${IS_ANDROID ? 'In Chrome: <b>⋮ menu → Add to Home screen</b>' : 'In Safari: <b>Share → Add to Home Screen</b>'} to install GymLog as a full-screen app. ${USER ? 'Your data syncs with your profile — sign in anywhere to see it.' : 'Guest data stays on this device — export a backup now and then!'}</div>
|
||||
<div class="small muted" style="line-height:1.5">📱 ${IS_ANDROID ? 'In Chrome: <b>⋮ menu → Add to Home screen</b>' : 'In Safari: <b>Share → Add to Home Screen</b>'} to install openGym as a full-screen app. ${USER ? 'Your data syncs with your profile — sign in anywhere to see it.' : 'Guest data stays on this device — export a backup now and then!'}</div>
|
||||
</div>
|
||||
<div class="dim small" style="text-align:center;margin-top:8px">GymLog · exercise data: hasaneyldrm/exercises-dataset (CC)</div>
|
||||
<div class="dim small" style="text-align:center;margin-top:8px">openGym · exercise data: hasaneyldrm/exercises-dataset (CC)</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
@@ -1857,7 +1857,7 @@ function viewSettings(app) {
|
||||
rd.onload = () => {
|
||||
try {
|
||||
const data = JSON.parse(rd.result);
|
||||
if (!data.workouts || !data.routines) throw new Error('not a GymLog backup');
|
||||
if (!data.workouts || !data.routines) throw new Error('not a openGym backup');
|
||||
if (!confirm('Replace all current data with this backup?')) return;
|
||||
S = Object.assign(JSON.parse(JSON.stringify(DEF)), data);
|
||||
save(); toast('Backup imported ✓'); route();
|
||||
|
||||
+5
-5
@@ -3,17 +3,17 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover,user-scalable=no">
|
||||
<title>GymLog</title>
|
||||
<title>openGym</title>
|
||||
<meta name="description" content="Personal gym & body weight tracker">
|
||||
<meta name="theme-color" content="#0c0e12">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<meta name="apple-mobile-web-app-title" content="GymLog">
|
||||
<meta name="apple-mobile-web-app-title" content="openGym">
|
||||
<link rel="manifest" href="manifest.json">
|
||||
<link rel="apple-touch-icon" href="icon-180.png">
|
||||
<link rel="icon" type="image/png" href="icon-180.png">
|
||||
<link rel="stylesheet" href="style.css?v=13">
|
||||
<link rel="stylesheet" href="style.css?v=14">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"><div style="padding-top:42vh;text-align:center;font-size:2.2rem">🏋️</div></div>
|
||||
@@ -45,7 +45,7 @@
|
||||
<div id="modal-root"></div>
|
||||
<div id="toast"></div>
|
||||
|
||||
<script src="data.js?v=13"></script>
|
||||
<script src="app.js?v=13"></script>
|
||||
<script src="data.js?v=14"></script>
|
||||
<script src="app.js?v=14"></script>
|
||||
</body>
|
||||
</html>
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "GymLog",
|
||||
"short_name": "GymLog",
|
||||
"name": "openGym",
|
||||
"short_name": "openGym",
|
||||
"description": "Personal gym & body weight tracker",
|
||||
"start_url": "./",
|
||||
"scope": "./",
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/* GymLog — mobile-first dark theme */
|
||||
/* openGym — mobile-first dark theme */
|
||||
:root{
|
||||
--bg:#0c0e12; --bg2:#14171d; --card:#1a1e26; --card2:#222733;
|
||||
--line:#2b3140; --txt:#eef1f6; --mut:#8b94a7; --dim:#5c6475;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* GymLog service worker — network-first for app shell, cache-first for media */
|
||||
const CACHE = 'gymlog-v13';
|
||||
const SHELL = ['./', 'index.html', 'style.css?v=13', 'app.js?v=13', 'data.js?v=13', 'manifest.json'];
|
||||
/* openGym service worker — network-first for app shell, cache-first for media */
|
||||
const CACHE = 'opengym-v14';
|
||||
const SHELL = ['./', 'index.html', 'style.css?v=14', 'app.js?v=14', 'data.js?v=14', 'manifest.json'];
|
||||
|
||||
self.addEventListener('install', e => {
|
||||
e.waitUntil(caches.open(CACHE).then(c => c.addAll(SHELL)).then(() => self.skipWaiting()));
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
name: opengym
|
||||
|
||||
services:
|
||||
# One-time: download the exercise images + GIFs into ./app (skipped if already there).
|
||||
# ~140 MB, from github.com/hasaneyldrm/exercises-dataset (CC).
|
||||
media:
|
||||
image: alpine/git
|
||||
volumes:
|
||||
- ./app/img:/out/img
|
||||
- ./app/gif:/out/gif
|
||||
entrypoint: ["/bin/sh", "-c"]
|
||||
command:
|
||||
- |
|
||||
if [ -z "$$(ls -A /out/img 2>/dev/null)" ]; then
|
||||
echo "↓ Downloading exercise media (~140 MB, one time)…"
|
||||
git clone --depth 1 https://github.com/hasaneyldrm/exercises-dataset /tmp/ds
|
||||
cp /tmp/ds/images/*.jpg /out/img/ && cp /tmp/ds/videos/*.gif /out/gif/
|
||||
echo "✓ Exercise media ready ($$(ls /out/img | wc -l) images)."
|
||||
else
|
||||
echo "✓ Exercise media already present — skipping download."
|
||||
fi
|
||||
restart: "no"
|
||||
|
||||
# Passkey auth + per-user data (Node, no framework).
|
||||
api:
|
||||
build: ./api
|
||||
restart: unless-stopped
|
||||
env_file: .env
|
||||
environment:
|
||||
- PORT=3000 # internal port (nginx proxies here) — do not change
|
||||
- DATA_DIR=/data
|
||||
volumes:
|
||||
- ./data:/data # users, passkeys, per-user state, session secret — BACK THIS UP
|
||||
|
||||
# Serves the app and proxies /api → api (single origin for passkeys).
|
||||
web:
|
||||
image: nginx:alpine
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
media:
|
||||
condition: service_completed_successfully
|
||||
api:
|
||||
condition: service_started
|
||||
ports:
|
||||
- "${WEB_PORT:-8080}:80"
|
||||
volumes:
|
||||
- ./app:/usr/share/nginx/html:ro
|
||||
- ./web/nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
@@ -0,0 +1,120 @@
|
||||
# Self-hosting openGym
|
||||
|
||||
openGym is two small containers (a web server and an API) plus a folder of your data.
|
||||
This guide takes you from "just cloned it" to "using it from my phone over the internet".
|
||||
|
||||
## 1. Run it locally (5 minutes)
|
||||
|
||||
Requirements: [Docker](https://docs.docker.com/get-docker/) with the Compose plugin.
|
||||
|
||||
```bash
|
||||
git clone https://github.com/DuarteSantos8/gym-app opengym
|
||||
cd opengym
|
||||
cp .env.example .env
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
- First start downloads the exercise images/GIFs (~140 MB) once into `app/img` and `app/gif`.
|
||||
- Open **http://localhost:8080** and create a profile with a passkey.
|
||||
|
||||
Check it's healthy:
|
||||
|
||||
```bash
|
||||
docker compose ps
|
||||
curl http://localhost:8080/api/health # {"ok":true,...}
|
||||
```
|
||||
|
||||
Logs: `docker compose logs -f`. Stop: `docker compose down`.
|
||||
|
||||
## 2. Understand the passkey requirement (important)
|
||||
|
||||
openGym signs you in with **passkeys** (WebAuthn). Browsers enforce two rules:
|
||||
|
||||
1. Passkeys are bound to an exact **hostname** (`RP_ID`).
|
||||
2. They only work over **HTTPS** — with one exception: `http://localhost`.
|
||||
|
||||
So `http://localhost:8080` works on the machine running Docker, but **another device (your
|
||||
phone) cannot use `http://<your-LAN-ip>:8080`** — that's neither localhost nor HTTPS, so the
|
||||
passkey prompt won't appear. To use openGym from your phone you need a real HTTPS hostname.
|
||||
|
||||
(You can still open it over LAN in **guest mode**, which stores data only in that browser.)
|
||||
|
||||
## 3. Expose it over HTTPS on your own domain
|
||||
|
||||
Put openGym behind something that terminates TLS for a hostname you control, then point it at
|
||||
the `web` container. Pick whichever you already run:
|
||||
|
||||
### Option A — Cloudflare Tunnel (no open ports)
|
||||
|
||||
1. Create a tunnel and route `gym.example.com` → `http://<docker-host>:8080`.
|
||||
2. Cloudflare gives you HTTPS automatically.
|
||||
|
||||
### Option B — Caddy (automatic Let's Encrypt)
|
||||
|
||||
```caddy
|
||||
gym.example.com {
|
||||
reverse_proxy localhost:8080
|
||||
}
|
||||
```
|
||||
|
||||
### Option C — Traefik / nginx / Nginx Proxy Manager
|
||||
|
||||
Route `gym.example.com` (HTTPS) → `web:80` (or `<docker-host>:8080`). Any reverse proxy works —
|
||||
openGym only needs the browser to reach it over `https://gym.example.com`.
|
||||
|
||||
Then set your domain in `.env` and restart:
|
||||
|
||||
```bash
|
||||
# .env
|
||||
RP_ID=gym.example.com
|
||||
ORIGIN=https://gym.example.com
|
||||
WEB_PORT=8080
|
||||
RP_NAME=openGym
|
||||
```
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
Visit `https://gym.example.com`, create your profile, and add it to your home screen
|
||||
(iOS: Share → Add to Home Screen · Android: ⋮ → Add to Home screen).
|
||||
|
||||
> Changing `RP_ID` later invalidates existing passkeys (they were bound to the old hostname).
|
||||
> Pick your domain before people register.
|
||||
|
||||
## 4. Multiple users
|
||||
|
||||
Anyone who can reach the URL can create their own profile — each gets isolated data. There's no
|
||||
admin/invite system by design; if you want it private, keep it behind your VPN, an auth proxy
|
||||
(Authelia, Cloudflare Access…), or just don't share the URL.
|
||||
|
||||
## 5. Backups
|
||||
|
||||
Everything is in `./data`:
|
||||
|
||||
```bash
|
||||
tar czf opengym-backup-$(date +%F).tar.gz data/
|
||||
```
|
||||
|
||||
That archive contains all profiles, passkeys and workout history. Restore by unpacking it back
|
||||
into the project folder. (Individual users can also export their own data as JSON from Settings.)
|
||||
|
||||
## 6. Updating
|
||||
|
||||
```bash
|
||||
git pull
|
||||
docker compose up -d --build
|
||||
```
|
||||
|
||||
The app shell is versioned (`?v=N`) so clients pick up changes on next load. Your `./data` and the
|
||||
downloaded media are untouched.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
| Symptom | Fix |
|
||||
|---|---|
|
||||
| No passkey prompt on my phone | You're on `http://` or an IP, not HTTPS. Set up a domain (section 3). |
|
||||
| "verification failed" on login | `RP_ID`/`ORIGIN` don't match the URL in the address bar. Make them exact, restart. |
|
||||
| Media didn't download | `docker compose logs media`. Re-run `docker compose up -d`, or run `./scripts/fetch-media.sh`. |
|
||||
| Port 8080 already used | Set `WEB_PORT=9090` in `.env` (and update `ORIGIN` for local testing). |
|
||||
| Want to reset a stuck login | Delete the cookie in your browser; sessions are just signed cookies. |
|
||||
@@ -1,12 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
# Holt die Übungs-Bilder (JPG) und Animationen (GIF) aus dem Upstream-Dataset.
|
||||
# Nicht im Repo, weil ~140 MB Binärdaten und 1:1 aus hasaneyldrm/exercises-dataset.
|
||||
# Manually download the exercise images (JPG) and animations (GIF).
|
||||
# You normally DON'T need this — `docker compose up` fetches them automatically.
|
||||
# Use it only if you run the app without Docker. Source: hasaneyldrm/exercises-dataset (CC).
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
tmp=$(mktemp -d)
|
||||
tmp="$(mktemp -d)"
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
git clone --depth 1 https://github.com/hasaneyldrm/exercises-dataset "$tmp"
|
||||
mkdir -p app/img app/gif
|
||||
cp "$tmp"/images/*.jpg app/img/
|
||||
cp "$tmp"/videos/*.gif app/gif/
|
||||
echo "OK: $(ls app/img | wc -l) Bilder, $(ls app/gif | wc -l) GIFs"
|
||||
echo "✓ $(ls app/img | wc -l) images, $(ls app/gif | wc -l) GIFs"
|
||||
@@ -0,0 +1,38 @@
|
||||
# openGym — standalone web server: serves the static app AND proxies /api to the backend,
|
||||
# so the whole app lives on ONE origin (required for WebAuthn / passkeys).
|
||||
server {
|
||||
listen 80;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# API → backend container
|
||||
location /api/ {
|
||||
proxy_pass http://api:3000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
# SPA fallback
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# App shell: always revalidate so updates show up immediately
|
||||
location ~* \.(js|css|json|html)$ {
|
||||
add_header Cache-Control "no-cache, must-revalidate";
|
||||
}
|
||||
|
||||
# Exercise images/GIFs never change → cache hard
|
||||
location ~* \.(png|jpg|jpeg|gif|ico|svg|woff|woff2|webp|avif)$ {
|
||||
expires 30d;
|
||||
add_header Cache-Control "public, max-age=2592000, immutable";
|
||||
}
|
||||
|
||||
gzip on;
|
||||
gzip_types text/plain text/css application/json application/javascript image/svg+xml;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
}
|
||||
Reference in new issue
Block a user