2019-07-14 18:18:41 +02:00
Installation
############
2021-11-03 12:41:23 +01:00
This application is written in Python (API) and Typescript (client):
2019-07-14 18:18:41 +02:00
- API:
- Flask
2020-07-15 15:30:41 +02:00
- `gpxpy <https://github.com/tkrajina/gpxpy> `_ to parse gpx files
- `staticmap <https://github.com/komoot/staticmap> `_ to generate a static map image from gpx coordinates
- `python-forecast.io <https://github.com/ZeevG/python-forecast.io> `_ to fetch weather data from `Dark Sky <https://darksky.net> `__ (former forecast.io)
- `dramatiq <https://flask-dramatiq.readthedocs.io/en/latest/> `_ for task queue
2022-07-14 18:36:19 +02:00
- `Authlib <https://docs.authlib.org/en/latest/> `_ for OAuth 2.0 Authorization support
2022-09-18 09:29:44 +02:00
- `Flask-Limiter <https://flask-limiter.readthedocs.io/en/stable> `_ for API rate limits
2019-07-14 18:18:41 +02:00
- Client:
2021-11-03 12:41:23 +01:00
- Vue3/Vuex
2019-07-14 18:18:41 +02:00
- `Leaflet <https://leafletjs.com/> `__ to display map
2021-11-03 12:41:23 +01:00
- `Chart.js <https://www.chartjs.org/> `__ to display charts with elevation and speed
2019-07-14 18:18:41 +02:00
2022-04-09 10:16:46 +02:00
| Logo, some sports and weather icons are made by `Freepik <https://www.freepik.com/> `__ from `www.flaticon.com <https://www.flaticon.com/> `__ .
| FitTrackee also uses icons from `Fork Awesome <https://forkaweso.me> `__ .
2019-07-14 18:18:41 +02:00
Prerequisites
~~~~~~~~~~~~~
2022-09-18 09:29:44 +02:00
- mandatory
- Python 3.7+
- PostgreSQL 10+
- optional
- Redis for task queue (if email sending is enabled) and API rate limits
- SMTP provider (if email sending is enabled)
- API key from `Dark Sky <https://darksky.net/dev> `__
- `Poetry <https://poetry.eustace.io> `__ (for installation from sources only)
- `Yarn <https://yarnpkg.com> `__ (for development only)
- Docker and Docker Compose (for development or evaluation purposes)
2019-07-14 18:18:41 +02:00
2020-09-19 13:56:14 +02:00
.. note ::
| The following steps describe an installation on Linux systems (tested
on Debian and Arch).
| On other OS, some issues can be encountered and adaptations may be
necessary.
Environment variables
~~~~~~~~~~~~~~~~~~~~~
.. warning ::
| Since FitTrackee 0.4.0, `` Makefile.custom.config `` is replaced by `` .env ``
The following environment variables are used by **FitTrackee** web application
or the task processing library. They are not all mandatory depending on
deployment method.
.. envvar :: FLASK_APP
| Name of the module to import at flask run.
| `` FLASK_APP `` should contain `` $(PWD)/fittrackee/__main__.py `` with installation from sources, else `` fittrackee `` .
.. envvar :: HOST
**FitTrackee** host.
2022-09-19 18:49:25 +02:00
:default: 127.0.0.1
2020-09-19 13:56:14 +02:00
.. envvar :: PORT
**FitTrackee** port.
:default: 5000
.. envvar :: APP_SETTINGS
**FitTrackee** configuration.
:default: fittrackee.config.ProductionConfig
.. envvar :: APP_SECRET_KEY
**FitTrackee** secret key, must be initialized in production environment.
2022-08-27 16:37:18 +02:00
.. warning ::
Use a strong secret key. This key is used in JWT generation.
2020-09-19 13:56:14 +02:00
.. envvar :: APP_WORKERS
Number of workers spawned by **Gunicorn** .
:default: 1
2021-07-16 19:33:32 +02:00
.. envvar :: APP_LOG
2020-09-19 13:56:14 +02:00
.. versionadded :: 0.4.0
Path to log file
2021-07-16 19:33:32 +02:00
.. envvar :: UPLOAD_FOLDER
2020-09-19 13:56:14 +02:00
.. versionadded :: 0.4.0
2022-07-03 17:27:43 +02:00
**Absolute path** to the directory where `uploads` folder will be created.
2020-09-19 13:56:14 +02:00
2022-07-03 17:27:43 +02:00
:default: `<application_directory>/fittrackee`
2020-09-19 13:56:14 +02:00
.. danger ::
| With installation from PyPI, the directory will be located in
**virtualenv** directory if the variable is not initialized.
.. envvar :: DATABASE_URL
| Database URL with username and password, must be initialized in production environment.
2021-04-06 13:15:26 +02:00
| For example in dev environment : `` postgresql://fittrackee:fittrackee@localhost:5432/fittrackee ``
2020-09-19 13:56:14 +02:00
2022-04-09 10:16:46 +02:00
.. warning ::
2021-04-07 10:43:20 +02:00
| Since `SQLAlchemy update (1.4+) <https://docs.sqlalchemy.org/en/14/changelog/changelog_14.html#change-3687655465c25a39b968b4f5f6e9170b> `__ ,
engine URL should begin with `postgresql://` .
2020-09-19 13:56:14 +02:00
2021-07-16 19:33:32 +02:00
.. envvar :: DATABASE_DISABLE_POOLING
2020-09-19 13:56:14 +02:00
.. versionadded :: 0.4.0
Disable pooling if needed (when starting application with **FitTrackee** entry point and not directly with **Gunicorn** ),
see `SqlAlchemy documentation <https://docs.sqlalchemy.org/en/13/core/pooling.html#using-connection-pools-with-multiprocessing-or-os-fork> `__ .
:default: false
.. envvar :: UI_URL
**FitTrackee** URL, needed for links in emails.
.. envvar :: EMAIL_URL
.. versionadded :: 0.3.0
Email URL with credentials, see `Emails <installation.html#emails> `__ .
2022-04-24 13:16:10 +02:00
.. versionchanged :: 0.6.5
:default: empty string
.. danger ::
If the email URL is empty, email sending will be disabled.
2021-11-14 22:12:29 +01:00
.. warning ::
If the email URL is invalid, the application may not start.
2020-09-19 13:56:14 +02:00
.. envvar :: SENDER_EMAIL
.. versionadded :: 0.3.0
**FitTrackee** sender email address.
.. envvar :: REDIS_URL
.. versionadded :: 0.3.0
2022-09-18 09:29:44 +02:00
Redis instance used by **Dramatiq** and **Flask-Limiter** .
2020-09-19 13:56:14 +02:00
:default: local Redis instance (``redis://``)
.. envvar :: WORKERS_PROCESSES
.. versionadded :: 0.3.0
Number of processes used by **Dramatiq** .
2022-09-18 09:29:44 +02:00
.. envvar :: API_RATE_LIMITS 🆕
.. versionadded :: 0.7.0
API rate limits, see `API rate limits <installation.html#api-rate-limits> `__ .
:default: `300 per 5 minutes`
2021-07-16 19:33:32 +02:00
.. envvar :: TILE_SERVER_URL
2020-09-19 13:56:14 +02:00
.. versionadded :: 0.4.0
2021-07-14 21:11:42 +02:00
| Tile server URL (with api key if needed), see `Map tile server <installation.html#map-tile-server> `__ .
2021-07-16 19:33:32 +02:00
| Since **0.4.9** , it's also used to generate static maps (to keep default server, see `DEFAULT_STATICMAP <installation.html#envvar-DEFAULT_STATICMAP> `__ )
2020-09-19 13:56:14 +02:00
:default: `https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png`
2022-09-18 09:29:44 +02:00
.. envvar :: STATICMAP_SUBDOMAINS
2022-07-13 13:02:12 +02:00
.. versionadded :: 0.6.10
| Some tile servers require a subdomain, see `Map tile server <installation.html#map-tile-server> `__ .
| For instance: "a,b,c" for OSM France.
:default: empty string
2021-07-16 19:33:32 +02:00
.. envvar :: MAP_ATTRIBUTION
2020-09-19 13:56:14 +02:00
.. versionadded :: 0.4.0
Map attribution (if using another tile server), see `Map tile server <installation.html#map-tile-server> `__ .
:default: `© <a href="http://www.openstreetmap.org/copyright" target="_blank" rel="noopener noreferrer">OpenStreetMap</a> contributors`
2022-07-13 13:02:12 +02:00
.. envvar :: DEFAULT_STATICMAP
2021-07-16 19:33:32 +02:00
.. versionadded :: 0.4.9
2022-07-13 13:02:12 +02:00
| If `True` , it keeps using default tile server to generate static maps (Komoot.de tile server).
| Otherwise, it uses the tile server set in `TILE_SERVER_URL <installation.html#envvar-TILE_SERVER_URL> `__ .
.. versionchanged :: 0.6.10
| This variable is now case-insensitive.
| If `False`, depending on tile server, `subdomains <installation.html#envvar-STATICMAP_SUBDOMAINS> `__ may be mandatory.
2021-07-16 19:33:32 +02:00
:default: False
2020-09-19 13:56:14 +02:00
.. envvar :: WEATHER_API_KEY
.. versionchanged :: 0.4.0 ⚠️ replaces `` WEATHER_API ``
**Dark Sky** API key for weather data (not mandatory).
2021-11-06 22:18:38 +01:00
.. envvar :: VUE_APP_API_URL
2020-09-19 13:56:14 +02:00
**FitTrackee** API URL, only needed in dev environment.
Emails
^^^^^^
.. versionadded :: 0.3.0
To send emails, a valid `` EMAIL_URL `` must be provided:
- with an unencrypted SMTP server: `` smtp://username:password@smtp.example.com:25 ``
- with SSL: `` smtp://username:password@smtp.example.com:465/?ssl=True ``
- with STARTTLS: `` smtp://username:password@smtp.example.com:587/?tls=True ``
2022-04-09 10:16:46 +02:00
.. warning ::
2022-04-23 08:28:41 +02:00
| - If the email URL is invalid, the application may not start.
| - Sending emails with Office365 may not work if SMTP auth is disabled.
2022-01-01 11:27:16 +01:00
2022-04-24 13:16:10 +02:00
.. versionchanged :: 0.5.3
2022-01-01 11:04:08 +01:00
2022-01-01 11:27:16 +01:00
| Credentials can be omitted: `` smtp://smtp.example.com:25 `` .
| If `` :<port> `` is omitted, the port defaults to 25.
2020-09-19 13:56:14 +02:00
2022-04-09 10:16:46 +02:00
.. warning ::
| Since 0.6.0, newly created accounts must be confirmed (an email with confirmation instructions is sent after registration).
Emails sent by FitTrackee are:
- account confirmation instructions
- password reset request
- email change (to old and new email adresses)
- password change
2022-04-24 13:16:10 +02:00
.. versionchanged :: 0.6.5
| For single-user instance, it is possible to disable email sending with an empty `` EMAIL_URL `` (in this case, no need to start dramatiq workers).
| A `CLI <cli.html#ftcli-users-update> `__ is available to activate account and modify email and password.
2022-04-09 10:16:46 +02:00
2020-09-19 13:56:14 +02:00
Map tile server
^^^^^^^^^^^^^^^
.. versionadded :: 0.4.0
Default tile server is now **OpenStreetMap** 's standard tile layer (if environment variables are not initialized).
The tile server can be changed by updating `` TILE_SERVER_URL `` and `` MAP_ATTRIBUTION `` variables (`list of tile servers <https://wiki.openstreetmap.org/wiki/Tile_servers> `__ ).
To keep using **ThunderForest Outdoors** , the configuration is:
- `` TILE_SERVER_URL=https://{s}.tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=XXXX `` where **XXXX** is **ThunderForest** API key
- `` MAP_ATTRIBUTION=© <a href="http://www.thunderforest.com/">Thunderforest</a>, © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors ``
.. note ::
| Check the terms of service of tile provider for map attribution
2022-07-13 13:02:12 +02:00
.. versionchanged :: 0.6.10
Since the tile server can be used for static map generation, some servers require a subdomain.
For instance, to set OSM France tile server, the expected values are:
- `` TILE_SERVER_URL=https://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png ``
2022-07-13 15:21:01 +02:00
- `` MAP_ATTRIBUTION='fond de carte par <a href="http://www.openstreetmap.fr/mentions-legales/" target="_blank" rel="nofollow noopener">OpenStreetMap France</a>, sous <a href="http://creativecommons.org/licenses/by-sa/2.0/fr/" target="_blank" rel="nofollow noopener">licence CC BY-SA</a>' ``
2022-07-13 13:02:12 +02:00
- `` STATICMAP_SUBDOMAINS=a,b,c ``
The subdomain will be chosen randomly.
2022-09-18 09:29:44 +02:00
API rate limits 🆕
^^^^^^^^^^^^^^^^^^
.. versionadded :: 0.7.0
| API rate limits are managed by `Flask-Limiter <https://flask-limiter.readthedocs.io/en/stable> `_ , based on IP with fixed window strategy.
| To enable rate limits, **Redis** must be available.
.. note ::
| If no Redis instance is available for rate limits, FitTrackee can still start.
| All endpoints are subject to rate limits, except endpoints serving assets.
| Limits can be modified by setting the environment variable `` API_RATE_LIMITS `` (see `Flask-Limiter documentation for notation <https://flask-limiter.readthedocs.io/en/stable/configuration.html#rate-limit-string-notation> `_ ).
| Rate limits must be separated by a comma, for instance:
.. code-block ::
export API_RATE_LIMITS="200 per day, 50 per hour"
**Flask-Limiter** provides a `Command Line Interface <https://flask-limiter.readthedocs.io/en/stable/cli.html> `_ for maintenance and diagnostic purposes.
.. code-block :: bash
$ flask limiter
Usage: flask limiter [OPTIONS] COMMAND [ARGS]...
Flask-Limiter maintenance & utility commmands
Options:
--help Show this message and exit.
Commands:
clear Clear limits for a specific key
config View the extension configuration
limits Enumerate details about all routes with rate limits
2022-02-05 22:09:17 +01:00
Installation
~~~~~~~~~~~~
2020-09-19 13:56:14 +02:00
.. warning ::
| Note that FitTrackee is under heavy development, some features may be unstable.
2019-07-14 18:18:41 +02:00
2022-02-05 22:09:17 +01:00
From PyPI
^^^^^^^^^
.. note ::
| Recommended way on production.
2020-09-19 13:56:14 +02:00
- Create and activate a virtualenv
- Install **FitTrackee** with pip
.. code-block :: bash
$ pip install fittrackee
- Create `` fittrackee `` database
Example :
.. code-block :: sql
CREATE USER fittrackee WITH PASSWORD '<PASSWORD>';
2022-10-30 08:49:51 +01:00
CREATE SCHEMA fittrackee AUTHORIZATION fittrackee;
CREATE DATABASE fittrackee OWNER fittrackee;
.. note ::
| see PostgreSQL `documentation <https://www.postgresql.org/docs/15/ddl-schemas.html> `_ for schema and privileges.
2020-09-19 13:56:14 +02:00
- Initialize environment variables, see `Environment variables <installation.html#environment-variables> `__
For instance, copy and update `` .env `` file from `` .env.example `` and source the file.
.. code-block :: bash
$ nano .env
$ source .env
2022-02-13 09:52:34 +01:00
- Initialize database schema
2020-09-19 13:56:14 +02:00
.. code-block :: bash
2022-04-24 13:16:10 +02:00
$ ftcli db upgrade
2020-09-19 13:56:14 +02:00
- Start the application
.. code-block :: bash
$ fittrackee
2022-11-27 12:06:42 +01:00
- Start task queue workers if email sending is enabled, with flask-dramatiq CLI:
2020-09-19 13:56:14 +02:00
.. code-block :: bash
2022-11-27 08:40:45 +01:00
$ flask worker --processes 2
2020-09-19 13:56:14 +02:00
.. note ::
| To start application and workers with **systemd** service, see `Deployment <installation.html#deployment> `__
2022-02-13 09:52:34 +01:00
- Open http://localhost:3000 and register
2022-03-27 15:11:12 +02:00
- To set admin rights to the newly created account, use the following command line:
2022-02-13 09:52:34 +01:00
.. code :: bash
2022-04-24 13:16:10 +02:00
$ ftcli users update <username> --set-admin true
2022-02-13 09:52:34 +01:00
2022-03-26 20:30:37 +01:00
.. note ::
If the user account is inactive, it activates it.
2020-09-19 13:56:14 +02:00
From sources
2022-02-05 22:09:17 +01:00
^^^^^^^^^^^^
2019-07-14 18:18:41 +02:00
2019-08-31 19:11:46 +02:00
.. warning ::
2020-09-19 13:56:14 +02:00
| Since FitTrackee 0.2.1, Python packages installation needs Poetry.
| To install it on ArchLinux:
2019-08-31 19:11:46 +02:00
.. code-block :: bash
2020-07-15 15:30:41 +02:00
$ yay poetry
2019-08-31 19:11:46 +02:00
$ poetry --version
2021-07-17 12:37:47 +02:00
Poetry 1.0.17
2019-08-31 19:11:46 +02:00
# optional
2020-07-15 15:30:41 +02:00
$ poetry config virtualenvs.in-project true
2019-08-31 19:11:46 +02:00
2020-07-15 15:30:41 +02:00
For other OS, see `Poetry Documentation <https://python-poetry.org/docs/#installation> `__
2019-08-31 19:11:46 +02:00
2019-07-14 18:18:41 +02:00
Dev environment
2020-09-19 13:56:14 +02:00
"""""""""""""""
2019-07-14 18:18:41 +02:00
- Clone this repo:
.. code :: bash
$ git clone https://github.com/SamR1/FitTrackee.git
$ cd FitTrackee
2021-07-10 10:46:44 +02:00
- Create **.env** from example and update it
2020-09-19 13:56:14 +02:00
(see `Environment variables <installation.html#environment-variables> `__ ).
2019-07-14 18:18:41 +02:00
2021-11-06 22:18:38 +01:00
- Install Python virtualenv, Vue and all related packages and
2019-07-14 18:18:41 +02:00
initialize the database:
.. code :: bash
$ make install-dev
$ make install-db
- Start the server and the client:
.. code :: bash
$ make serve
2020-07-15 15:30:41 +02:00
- Run dramatiq workers:
.. code :: bash
$ make run-workers
2022-02-13 09:52:34 +01:00
- Open http://localhost:3000 and register
2022-03-27 15:11:12 +02:00
- To set admin rights to the newly created account, use the following command line:
2022-02-13 09:52:34 +01:00
.. code :: bash
2022-04-24 13:16:10 +02:00
$ make user-set-admin USERNAME=<username>
2019-07-14 18:18:41 +02:00
2022-03-27 15:11:12 +02:00
.. note ::
If the user account is inactive, it activates it.
2020-09-19 13:56:14 +02:00
Production environment
""""""""""""""""""""""
2019-07-14 18:18:41 +02:00
2019-07-24 16:18:38 +02:00
.. warning ::
2020-09-19 13:56:14 +02:00
| Note that FitTrackee is under heavy development, some features may be unstable.
2019-07-24 16:18:38 +02:00
2022-11-27 12:06:42 +01:00
- Download the last release (for now, it is the release v0.7.7):
2019-07-14 18:18:41 +02:00
.. code :: bash
2022-11-27 12:06:42 +01:00
$ wget https://github.com/SamR1/FitTrackee/archive/v0.7.7.tar.gz
$ tar -xzf v0.7.7.tar.gz
$ mv FitTrackee-0.7.7 FitTrackee
2019-07-14 18:18:41 +02:00
$ cd FitTrackee
2021-07-10 10:46:44 +02:00
- Create **.env** from example and update it
2020-09-19 13:56:14 +02:00
(see `Environment variables <installation.html#environment-variables> `__ ).
2019-07-14 18:18:41 +02:00
2020-09-19 13:56:14 +02:00
- Install Python virtualenv and all related packages:
2019-07-14 18:18:41 +02:00
.. code :: bash
2020-09-19 13:56:14 +02:00
$ make install-python
2019-07-14 18:18:41 +02:00
2020-09-19 13:56:14 +02:00
- Initialize the database (**after updating** `` db/create.sql `` **to change
database credentials**):
2019-07-14 18:18:41 +02:00
.. code :: bash
2020-09-19 13:56:14 +02:00
$ make install-db
2019-07-14 18:18:41 +02:00
2020-09-19 13:56:14 +02:00
- Start the server and dramatiq workers:
2019-07-14 18:18:41 +02:00
.. code :: bash
$ make run
2022-04-24 13:16:10 +02:00
.. note ::
If email sending is disabled: `` $ make run-server ``
2022-02-13 09:52:34 +01:00
- Open http://localhost:5000 and register
2022-03-27 15:11:12 +02:00
- To set admin rights to the newly created account, use the following command line:
2022-02-13 09:52:34 +01:00
.. code :: bash
2022-04-24 13:16:10 +02:00
$ make user-set-admin USERNAME=<username>
2019-07-14 18:18:41 +02:00
2022-03-27 15:11:12 +02:00
.. note ::
If the user account is inactive, it activates it.
2022-02-05 22:09:17 +01:00
2019-07-14 18:18:41 +02:00
Upgrade
2022-02-05 22:09:17 +01:00
~~~~~~~
2019-07-14 18:18:41 +02:00
2019-07-21 09:29:34 +02:00
.. warning ::
| Before upgrading, make a backup of all data:
| - database (with `pg_dump <https://www.postgresql.org/docs/11/app-pgdump.html> `__ for instance)
2020-09-19 13:56:14 +02:00
| - upload directory (see `Environment variables <installation.html#environment-variables> `__ )
2019-07-21 09:29:34 +02:00
2022-02-05 22:09:17 +01:00
From PyPI
^^^^^^^^^
2022-04-09 10:16:46 +02:00
- Stop the application and activate the virtualenv
2022-02-05 22:09:17 +01:00
- Upgrade with pip
.. code-block :: bash
$ pip install -U fittrackee
- Update environment variables if needed and source environment variables file
.. code-block :: bash
$ nano .env
$ source .env
- Upgrade database if needed (see changelog for migrations):
.. code-block :: bash
2022-04-24 13:16:10 +02:00
$ ftcli db upgrade
2022-02-05 22:09:17 +01:00
2022-04-24 13:16:10 +02:00
- Restart the application and task queue workers (if email sending is enabled).
2022-02-05 22:09:17 +01:00
From sources
^^^^^^^^^^^^
2019-07-21 09:29:34 +02:00
Dev environment
2020-09-19 13:56:14 +02:00
"""""""""""""""
2019-07-21 09:29:34 +02:00
- Stop the application and pull the repository:
.. code :: bash
$ git pull
2021-07-17 12:37:47 +02:00
- Update **.env** if needed (see `Environment variables <installation.html#environment-variables> `__ ).
2019-07-21 09:29:34 +02:00
2022-02-05 22:09:17 +01:00
- Upgrade packages:
2019-07-21 09:29:34 +02:00
.. code :: bash
$ make install-dev
2022-02-05 22:09:17 +01:00
- Upgrade database if needed (see changelog for migrations):
.. code :: bash
2019-08-31 19:11:46 +02:00
$ make upgrade-db
2019-07-21 09:29:34 +02:00
2020-09-19 13:56:14 +02:00
- Restart the server:
2019-07-21 09:29:34 +02:00
.. code :: bash
$ make serve
2020-09-19 13:56:14 +02:00
- Run dramatiq workers:
.. code :: bash
$ make run-workers
2019-07-21 09:29:34 +02:00
Prod environment
2020-09-19 13:56:14 +02:00
""""""""""""""""
2019-07-21 09:29:34 +02:00
2021-07-17 12:37:47 +02:00
- Stop the application
- Change to the directory where FitTrackee directory is located
2022-11-27 12:06:42 +01:00
- Download the last release (for now, it is the release v0.7.7) and overwrite existing files:
2019-07-14 18:18:41 +02:00
2020-09-19 13:56:14 +02:00
.. code :: bash
2019-08-31 14:55:50 +02:00
2022-11-27 12:06:42 +01:00
$ wget https://github.com/SamR1/FitTrackee/archive/v0.7.7.tar.gz
$ tar -xzf v0.7.7.tar.gz
$ cp -R FitTrackee-0.7.7/* FitTrackee/
2021-07-17 12:37:47 +02:00
$ cd FitTrackee
2019-08-31 14:55:50 +02:00
2021-07-17 12:37:47 +02:00
- Update **.env** if needed (see `Environment variables <installation.html#environment-variables> `__ ).
2020-07-15 15:30:41 +02:00
2022-02-05 22:09:17 +01:00
- Upgrade packages:
.. code :: bash
$ make install-dev
- Upgrade database if needed (see changelog for migrations):
2020-07-15 15:30:41 +02:00
2020-09-19 13:56:14 +02:00
.. code :: bash
2020-07-15 15:30:41 +02:00
2020-09-19 13:56:14 +02:00
$ make upgrade-db
2020-07-15 15:30:41 +02:00
2020-09-19 13:56:14 +02:00
- Restart the server and dramatiq workers:
2020-09-16 13:01:15 +02:00
2020-09-19 13:56:14 +02:00
.. code :: bash
2020-09-16 13:01:15 +02:00
2020-09-19 13:56:14 +02:00
$ make run
2020-09-16 13:01:15 +02:00
2022-04-24 13:16:10 +02:00
.. note ::
If email sending is disabled: `` $ make run-server ``
2020-09-16 13:01:15 +02:00
2020-09-19 13:56:14 +02:00
Deployment
2022-02-05 22:09:17 +01:00
~~~~~~~~~~
2020-09-16 13:01:15 +02:00
2020-09-19 13:56:14 +02:00
There are several ways to start **FitTrackee** web application and task queue
library.
One way is to use a **systemd** services and **Nginx** to proxy pass to **Gunicorn** .
Examples (to update depending on your application configuration and given distribution):
- for application: `` fittrackee.service ``
.. code-block ::
[Unit]
Description=FitTrackee service
After=network.target
After=postgresql.service
After=redis.service
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=<USER>
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=fittrackee
Environment="APP_SECRET_KEY="
Environment="APP_LOG="
Environment="UPLOAD_FOLDER="
Environment="DATABASE_URL="
Environment="UI_URL="
Environment="EMAIL_URL="
Environment="SENDER_EMAIL="
Environment="REDIS_URL="
Environment="TILE_SERVER_URL="
2022-07-13 15:21:01 +02:00
Environment="STATICMAP_SUBDOMAINS="
2020-09-19 13:56:14 +02:00
Environment="MAP_ATTRIBUTION="
Environment="WEATHER_API_KEY="
WorkingDirectory=/home/<USER>/<FITTRACKEE DIRECTORY>
ExecStart=/home/<USER>/<FITTRACKEE DIRECTORY>/.venv/bin/gunicorn -b 127.0.0.1:5000 "fittrackee:create_app()" --error-logfile /home/<USER>/<FITTRACKEE DIRECTORY>/gunicorn.log
Restart=always
[Install]
WantedBy=multi-user.target
2021-02-21 00:09:10 +01:00
.. note ::
More information on `Gunicorn documentation <https://docs.gunicorn.org/en/stable/deploy.html> `__
2020-09-19 13:56:14 +02:00
- for task queue workers: `` fittrackee_workers.service ``
.. code-block ::
[Unit]
Description=FitTrackee task queue service
After=network.target
After=postgresql.service
After=redis.service
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=<USER>
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=fittrackee_workers
Environment="FLASK_APP=fittrackee"
Environment="APP_SECRET_KEY="
Environment="APP_LOG="
Environment="UPLOAD_FOLDER="
Environment="DATABASE_URL="
Environment="UI_URL="
Environment="EMAIL_URL="
Environment="SENDER_EMAIL="
Environment="REDIS_URL="
WorkingDirectory=/home/<USER>/<FITTRACKEE DIRECTORY>
ExecStart=/home/<USER>/<FITTRACKEE DIRECTORY>/.venv/bin/flask worker --processes <NUMBER OF PROCESSES>
Restart=always
[Install]
WantedBy=multi-user.target
- **Nginx** configuration:
.. code-block ::
server {
2022-02-05 22:09:17 +01:00
listen 443 ssl http2;
2020-09-19 13:56:14 +02:00
server_name example.com;
ssl_certificate fullchain.pem;
ssl_certificate_key privkey.pem;
2022-11-04 16:46:26 +01:00
## this parameter controls how large of a file can be
## uploaded, and defaults to 1MB. If you change the FitTrackee
## settings to allow larger uploads, you'll need to change this
## setting by uncommenting the line below and setting the size limit
## you want. Set to "0" to prevent nginx from checking the
## request body size at all
# client_max_body_size 1m;
2020-09-19 13:56:14 +02:00
location / {
proxy_pass http://127.0.0.1:5000;
proxy_redirect default;
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-Host $server_name;
2022-08-27 16:37:18 +02:00
proxy_set_header X-Forwarded-Proto $scheme;
2020-09-19 13:56:14 +02:00
}
}
server {
listen 80;
server_name example.com;
location / {
return 301 https://example.com$request_uri;
}
}
2020-09-16 13:01:15 +02:00
.. note ::
2021-02-21 00:09:10 +01:00
If needed, update configuration to handle larger files (see `client_max_body_size <https://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size> `_ ).
2021-01-31 12:03:17 +01:00
Docker
~~~~~~
2021-10-17 09:28:56 +02:00
Installation
^^^^^^^^^^^^
2021-01-31 19:19:47 +01:00
.. versionadded :: 0.4.4
2021-01-31 12:03:17 +01:00
2022-04-09 10:16:46 +02:00
For evaluation purposes, docker files are available, installing **FitTrackee** from **sources** .
2021-01-31 12:03:17 +01:00
2022-07-23 11:56:03 +02:00
- To install **FitTrackee** :
2021-01-31 12:03:17 +01:00
.. code-block :: bash
$ git clone https://github.com/SamR1/FitTrackee.git
$ cd FitTrackee
2022-06-18 16:44:20 +02:00
$ cp .env.docker .env
2022-07-23 11:56:03 +02:00
$ make docker-build
2021-01-31 12:03:17 +01:00
2022-07-23 11:56:03 +02:00
- To initialise database:
.. code-block :: bash
2022-09-14 09:55:02 +02:00
$ make docker-init
2022-07-23 11:56:03 +02:00
- Open http://localhost:5000 and register.
2021-01-31 12:03:17 +01:00
Open http://localhost:8025 to access `MailHog interface <https://github.com/mailhog/MailHog> `_ (email testing tool)
2022-03-27 15:11:12 +02:00
- To set admin rights to the newly created account, use the following command line:
2022-02-13 09:52:34 +01:00
.. code :: bash
$ make docker-set-admin USERNAME=<username>
2022-03-27 15:11:12 +02:00
.. note ::
If the user account is inactive, it activates it.
2021-01-31 12:03:17 +01:00
- To stop **Fittrackee** :
.. code-block :: bash
$ make docker-stop
- To start **Fittrackee** (application and dramatiq workers):
.. code-block :: bash
$ make docker-run-all
- To run shell inside **Fittrackee** container:
.. code-block :: bash
2021-10-17 09:28:56 +02:00
$ make docker-shell
2021-11-06 22:18:38 +01:00
Development
^^^^^^^^^^^
2021-10-17 09:28:56 +02:00
2021-11-06 22:18:38 +01:00
.. versionadded :: 0.5.0
2021-10-17 09:28:56 +02:00
2022-02-05 22:09:17 +01:00
- an additional step is needed to install `fittrackee_client`
2021-10-17 09:28:56 +02:00
.. code-block :: bash
$ make docker-build-client
2021-11-06 22:18:38 +01:00
- to start **FitTrackee** with client dev tools:
2021-10-17 09:28:56 +02:00
.. code-block :: bash
2021-11-06 22:18:38 +01:00
$ make docker-serve-client
2022-02-13 09:52:34 +01:00
Open http://localhost:3000
2021-11-06 22:18:38 +01:00
.. note ::
2022-07-23 11:56:03 +02:00
Some environment variables need to be updated like `UI_URL`
- to run lint or tests:
.. code-block :: bash
2022-07-23 16:55:57 +02:00
$ make docker-lint-client # run lint on javascript files
$ make docker-test-client # run unit tests on Client
$ make docker-lint-python # run type check and lint on python files
$ make docker-test-python # run unit tests on API