Endurain
Introduction
Workouts and nerd do not blend together. Right?
Most of the time they do not, but there are a few nerds who like to run.
I know a few of them myself included.
I also wanted to a way to track my walks and runs in my homelab.
After searching a bit I found Endurain which is essentially a self hosted version of Strava.
If you already use Strava you can also connect your Strava account to Endurain.
I must confess I struggled quite a bit with this deploy, because it was my first time figuring out creating API-users to connect 2 applications.
Preparations
First create another user than root if you haven't already.
sudo adduser USERNAME
cat /etc/group
sudo adduser USERNAME sudo
groups #check the result of the last command
Secondly update your container/VM and install the needed software.
sudo apt update && sudo apt upgrade -y
sudo apt install curl -y
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
sudo adduser USERNAME docker
groups #check if you are part of the Docker group
docker run hello-world
Installing Endurain
After the preparations it is time to install Endurain.
During this process you will create the needed directory structure and downloading the example Docker Compose files.
sudo mkdir /opt/endurain
id #checking your id which is needed for chown
sudo chown 1000:1000 /opt/endurain
mkdir -p \
/opt/endurain/backend/{user_images,server_images,files,logs} \
/opt/endurain/postgres
cd /opt/endurain
wget https://raw.githubusercontent.com/joaovitoriasilva/endurain/refs/heads/master/docker-compose.yml.example
wget https://raw.githubusercontent.com/joaovitoriasilva/endurain/refs/heads/master/.env.example
mv docker-compose.yml.example docker-compose.yml
mv .env.example .env
vim .env #Change the changme values in .env
Example .env file
The values in the .env file are still on their defaults.
Of course for security reasons you will need to change the credentials and set the values to match your environment.
After editing the .env file you are reading to bring the container up and check the logs if all goes well.
sudo docker compose up -d
sudo docker compose logs -f
ip a | grep xxx.xxx.xxx # fill in the parts of the IP-address which you know of your network
When the Docker containers are up and running (no pun intended) without errors you can add the Endurain to your reserve proxy configuration (if you have set up a reserve proxy).
Afterwards you are now ready to navigate to your Endurain instance for the first time!
Navigate to endurain.example.com and login with the default values first.
login with admin - admin
Logged in, change the admin password someting stronger and create your own account.
- After logging in, navigate to the top and click on the gear icon.
- Navigate to security to change the password of the admin account.
- Then navigate to Users to create your own user account.
- Click on Add User.
- Insert the needed information of the user (Username, Name, Email, Password).
- After clicking on Add user, the user can modify their details however they like.
Strava
Creating your API-application
- Login to Strava
- Go to https://www.strava.com/settings/api and create an API for your application.
Required information: - Application Name
- Category
- Club: Not required, but you can select it if you like
- Website: Your Endurain instance
- Application Description
- Authorization Callback Domain: the root domain of your Endurain website
- An application image is also required
Explanation of the values in the API application screen:
- Category: The category you chose for your application
- Club: Will show if you have a club associated with your application
- Client ID: Your application ID
- Client Secret: Your client secret (please keep this confidential)
- Authorization token: Your authorization token which will change every six hours (please keep this confidential)
- Your Refresh token: The token you will use to get a new authorization token (please keep this confidential)
- Rate limits: Your current rate limit
- Authorization Callback Domain: When building your app, change “Authorization Callback Domain” to localhost or any domain. When taking your app live, change “Authorization Callback Domain” to a real domain
Testing your API
- Make a curl command on the Endurain host:
After this you should see your Athlete information from Strava with the API-token you created. - Edit this URL - http://www.strava.com/oauth/authorize?client_id=[REPLACE_WITH_YOUR_CLIENT_ID]&response_type=code&redirect_uri=http://localhost/exchange_token&approval_prompt=force&scope=read
- Open a browser and paste the edited URL
- Hit enter
- When you see the authorization page, click Authorize
- Copy the authorization code
- Make a CURL request to exchange the authorization code and scope for a refresh token, access token, and access token expiration date
Replace the client_secret and code. The response should include the refresh token, access token, and access token expiration date - curl -X POST https://www.strava.com/oauth/token \
-F client_id=YOURCLIENTID \
-F client_secret=YOURCLIENTSECRET \
-F code=AUTHORIZATIONCODE \
-F grant_type=authorization_code - If all the steps give results from the API then everything is working correctly
Connecting Strava to Endurain
- Go back to Endurain
- Click the settings gear and navigate to integrations
- Click on connect next to Strava
- Insert your Cliend ID and Client Secret
- Authorize Endurain
- Under options you can optionally retrieve activities by days and retrieve gear, but when you connect the first time it should import those things automatically
After this challenging deploy you are now ready challenge yourself during the workouts.