cd ~/Dokumenti/scripts/Fitnes-tracker # Stop the container docker compose down # Create the folder if it doesn't exist (safe to run even if it exists) mkdir -p fitness-data # Make sure container user (uid 1000) can write there sudo chown -R 1000:1000 fitness-data sudo chmod 775 fitness-data # Start again docker compose up Fitness Tracker – Self-Hosted 5×5 Powerlifting App A minimal self-hosted fitness tracker built in Go. Includes: Workout logging with start/finish A/B templates (StrongLifts style) Automatic rest-time tracking Volume tracking (today/week/month) SQLite database Fully Dockerized (with UID/GID support) External fitness.db mounted to host This app is designed to be simple, private, and fast, perfect for home servers or local use. 📁 Project Structure Fitnes-tracker/ │── main.go │── go.mod │── Dockerfile │── docker-compose.yml │── readme.md │── fitness-data/ # External volume (database lives here) │ └── fitness.db 🔥 1. Running Locally (Development Mode) Install Go Ubuntu / Debian: sudo apt update sudo apt install -y golang-go Verify: go version Run the app Inside the project folder: cd Fitnes-tracker DATABASE_URL=./fitness.db go run main.go Open in browser: 👉 http://localhost:8080 Local DB file will be created as: ./fitness.db 🐳 2. Running with Docker (Recommended) Make sure Docker + docker-compose are installed: sudo apt install -y docker.io docker-compose-plugin sudo usermod -aG docker $USER newgrp docker Create external DB directory mkdir -p fitness-data Fix permissions so container user (UID 1000) can write sudo chown -R 1000:1000 fitness-data sudo chmod 775 fitness-data Build the Docker image docker compose build Start the app docker compose up -d Check logs: docker compose logs -f You should see: Using database file: /data/fitness.db Listening on :8080 ... Open: 👉 http://localhost:8080 🔧 3. Docker Compose Explained Your docker-compose.yml: services: fitness: build: . container_name: fitness-tracker restart: unless-stopped environment: - DATABASE_URL=/data/fitness.db volumes: - ./fitness-data:/data ports: - "8080:8080" What it does: Mounts ./fitness-data → /data inside container SQLite DB stored on host: fitness-data/fitness.db App always restarts unless manually stopped Binds port 8080 (browser UI) 👤 4. Running container as UID 1000:1000 The app inside the container runs as a regular Linux user (not root). This avoids permission issues and is safer. To check container UID/GID: docker exec -it fitness-tracker id Expected output: uid=1000(appuser) gid=1000(appuser) If permissions are wrong, fix host directory: sudo chown -R 1000:1000 fitness-data sudo chmod 775 fitness-data 📦 5. Rebuilding & Updating Whenever you modify Go code: docker compose build docker compose up -d If you want to clean old images: docker system prune -f 📤 6. Production Setup (Traefik Support) To put behind Traefik: Add labels inside docker-compose.yml: labels: - "traefik.enable=true" - "traefik.http.routers.fitness.rule=Host(`fitness.rozic-dev.com`)" - "traefik.http.routers.fitness.entrypoints=websecure" - "traefik.http.routers.fitness.tls.certresolver=letsencrypt" - "traefik.http.services.fitness.loadbalancer.server.port=8080" networks: - traefik_default 💾 7. Backup Just back up the fitness-data/ folder: cp -r fitness-data fitness-data-backup Or tar it: tar -czvf fitness-backup.tar.gz fitness-data/ 📚 8. Git Instructions Set your identity once: git config --global user.name "Dejan R." git config --global user.email "dejan@example.com" Useful Commands git add . git commit -m "update" git push .gitignore (already included) *.db fitness-data/ DB files will never pollute your git history.