SamR1/docker-fittrackee

Getting error "[Makefile:13: migrate] Fehler 1"

Closed this issue · 17 comments

fr567 commented

Dear all,

I tried to install docker-fittrackee, but I got the following error:

fittrackee_error

It seems, that two dcoker containers start, but I can't connect to port 5000. This was the first installation from Fittrackee.

THX for this great software

Edit 20230528:
I get the error during excecution excecute make build up init

SamR1 commented

Hi,

Are there any errors in FitTrackee logs?

fr567 commented

Hi,

thanks for the quick anwer. Unfortunately the logs directory is empty. Enclose my .env:

# Custom variables initialisation
# All uncommented variables must be initialized

# Host directory to store FitTrackee logs (must be an absolute path)
FITTRACKEE_LOG_DIR=/home/duncan/docker/docker-fittrackee/logs

# Application
FLASK_APP=fittrackee
FLASK_SKIP_DOTENV=1
PORT=5000
APP_SETTINGS=fittrackee.config.ProductionConfig
APP_SECRET_KEY='my_secret_key'
APP_LOG=/home/duncan/docker/docker-fittrackee/logs/fittrackee.log
UPLOAD_FOLDER=/home/duncan/docker/docker-fittrackee/uploads
# gunicorn settings
# see https://docs.gunicorn.org/en/stable/settings.html#worker-processes
APP_WORKERS=2
GUNICORN_LOG=/home/duncan/docker/docker-fittrackee/logs/gunicorn.log
GUNICORN_TIMEOUT=300
GUNICORN_THREADS=4

# PostgreSQL
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
DATABASE_URL=postgresql://fittrackee:fittrackee@fittrackee-db:5432/fittrackee
#DATABASE_DISABLE_POOLING=

# Redis (required for API rate limits, email sending and user export)
#REDIS_URL=redis://redis:6379

# API rate limits (needs redis running)
#API_RATE_LIMITS="300 per 5 minutes"

# Emails
# since fittrackee 0.6.5, email sending can be disabled
# see documentation https://samr1.github.io/FitTrackee/installation.html#emails
#UI_URL=
#EMAIL_URL=
#SENDER_EMAIL=
#WORKERS_PROCESSES=2

# Workouts
#export TILE_SERVER_URL=
#export STATICMAP_SUBDOMAINS=
#export MAP_ATTRIBUTION=
#export DEFAULT_STATICMAP=False

# Weather
# available weather API providers: darksky, visualcrossing
#export WEATHER_API_PROVIDER=
#export WEATHER_API_KEY=

THX

Edit 20230528:
I'm using a raspberry pi 4 with the latest bullseye release

SamR1 commented

Hi,

I think the error is related to the env variables APP_LOG and UPLOAD_FOLDER (which are directories in the docker container).
Can you try with initial values?

APP_LOG=/logs/fittrackee.log
UPLOAD_FOLDER=/uploads
fr567 commented

Hi,

so enclose my new .env. I also set GUNICORN_LOG back to the the default value again. The directory /home/duncan/docker/docker-fittrackee/logs is unfortunately still empty and the error is the same make: *** [Makefile:13: migrate] Fehler 1.

Any ideas here? I looks like it get stuck in the migrate part of the Makefile. Is this needed if I install it the first time?


# Custom variables initialisation
# All uncommented variables must be initialized

# Host directory to store FitTrackee logs (must be an absolute path)
FITTRACKEE_LOG_DIR=/home/duncan/docker/docker-fittrackee/logs

# Application
FLASK_APP=fittrackee
FLASK_SKIP_DOTENV=1
PORT=5000
APP_SETTINGS=fittrackee.config.ProductionConfig
APP_SECRET_KEY='my_secret_key'
APP_LOG=/logs/fittrackee.log
UPLOAD_FOLDER=/uploads
# gunicorn settings
# see https://docs.gunicorn.org/en/stable/settings.html#worker-processes
APP_WORKERS=2
GUNICORN_LOG=/logs/gunicorn.log
GUNICORN_TIMEOUT=300
GUNICORN_THREADS=4

# PostgreSQL
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
DATABASE_URL=postgresql://fittrackee:fittrackee@fittrackee-db:5432/fittrackee
#DATABASE_DISABLE_POOLING=

# Redis (required for API rate limits, email sending and user export)
#REDIS_URL=redis://redis:6379

# API rate limits (needs redis running)
#API_RATE_LIMITS="300 per 5 minutes"

# Emails
# since fittrackee 0.6.5, email sending can be disabled
# see documentation https://samr1.github.io/FitTrackee/installation.html#emails
#UI_URL=
#EMAIL_URL=
#SENDER_EMAIL=
#WORKERS_PROCESSES=2

# Workouts
#export TILE_SERVER_URL=
#export STATICMAP_SUBDOMAINS=
#export MAP_ATTRIBUTION=
#export DEFAULT_STATICMAP=False

# Weather
# available weather API providers: darksky, visualcrossing
#export WEATHER_API_PROVIDER=
#export WEATHER_API_KEY=
SamR1 commented

Hi,

can you rebuild the container and run each step separately?

$ make build
$ make up
$ make migrate
$ make run
fr567 commented

Hi,

again thanks for the amazing support. So to trigger a rebuild I changed the secret key in the .env. (I don't know if this is enough). After that I excecuted make build. This finished without an error.
make_build

Then I excecuted make up. This also finished without an error:
make_up

Then I excecuted make migrate, which leads to the already known error:
make_migrate

Then I executed make run, which leads to the following error:
make_run

SamR1 commented

something is preventing the migration execution.

with make migrate command, the error should be displayed, for instance with an invalid path:

$ make migrate
Traceback (most recent call last):
  File "/usr/src/app/.venv/bin/ftcli", line 5, in <module>
    from fittrackee.cli import cli
  File "/usr/src/app/.venv/lib/python3.9/site-packages/fittrackee/__init__.py", line 34, in <module>
    logging.basicConfig(
  File "/usr/local/lib/python3.9/logging/__init__.py", line 2003, in basicConfig
    h = FileHandler(filename, mode,
  File "/usr/local/lib/python3.9/logging/__init__.py", line 1146, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/local/lib/python3.9/logging/__init__.py", line 1175, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding,
FileNotFoundError: [Errno 2] No such file or directory: '<invalid_path>/logs/fittrackee.log'
make: *** [Makefile:13: migrate] Error 1

I never used docker-compose on a rasberry pi (my current FitTrackee instance is installed on a Raspberry Pi 4 but without docker (and with another OS)).

Did you delete the existing container before rebuilding it?

fr567 commented

What do you mean exactly with

Did you delete the existing container before rebuilding it?

Do you mean that the container is not showing up in docker container ls anymore?

THX

SamR1 commented

with docker container rm command, for instance to remove the application container:

$ docker container ls
CONTAINER ID   IMAGE                             COMMAND                  CREATED          STATUS          PORTS                                                                                  NAMES
cdf3cf0da326   docker-fittrackee-fittrackee      "/usr/src/app/docker…"   29 minutes ago   Up 29 minutes   0.0.0.0:5020->5000/tcp, :::5020->5000/tcp                                              fittrackee
b0b754295e14   docker-fittrackee-fittrackee-db   "docker-entrypoint.s…"   29 minutes ago   Up 29 minutes   5432/tcp                                                                               fittrackee-db
f18db6f2265e   redis:latest                      "docker-entrypoint.s…"   15 hours ago     Up 30 minutes   0.0.0.0:6379->6379/tcp, :::6379->6379/tcp                                              fittrackee-redis
$ docker container stop cdf3cf0da326
cdf3cf0da326
$ docker container rm cdf3cf0da326
cdf3cf0da326

I'm not sure it'll fix the issue, but it's just to be sure to restart with a clean container.

fr567 commented

Mhh, still get the error. When the docker-fittrackee-fitrackee container should be started by the make script and visible in docker container ls? Should it be before make migrate is excecuted?

fr567 commented

So I have some more information. It looks like the fittrackee container is not started correctly. I started docker-compose up without the option -d manually and got the following error message:

fittrackee-redis | 1:M 29 May 2023 08:45:02.881 * Ready to accept connections
fittrackee       | /usr/lib/python3/dist-packages/supervisor/options.py:474: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (includinrobably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
fittrackee       |   self.warnings.warn(
fittrackee       | Error: Format string '.venv/bin/flask worker --processes %(ENV_WORKERS_PROCESSES)s' for 'program:fittrackee-workers.command' contains names ('ENV_WORKERS_PROCESSES') which cannot OG, ENV_APP_SECRET_KEY, ENV_APP_SETTINGS, ENV_APP_WORKERS, ENV_DATABASE_URL, ENV_FITTRACKEE_LOG_DIR, ENV_FLASK_APP, ENV_FLASK_SKIP_DOTENV, ENV_GPG_KEY, ENV_GUNICORN_LOG, ENV_GUNICORN_THREADS, ENV_GU ENV_LANG, ENV_OLDPWD, ENV_PATH, ENV_PORT, ENV_POSTGRES_PASSWORD, ENV_POSTGRES_USER, ENV_PWD, ENV_PYTHON_GET_PIP_SHA256, ENV_PYTHON_GET_PIP_URL, ENV_PYTHON_PIP_VERSION, ENV_PYTHON_SETUPTOOLS_VERSIONLOAD_FOLDER, ENV_VIRTUAL_ENV, ENV__, group_name, here, host_node_name, numprocs, process_num, program_name in section 'program:fittrackee-workers' (file: '/etc/supervisor/conf.d/fittrackee-workers.s
fittrackee       | For help, use /usr/bin/supervisord -h
fittrackee exited with code 2
^X^CGracefully stopping... (press Ctrl+C again to force)
Stopping fittrackee-db    ... done
Stopping fittrackee-redis ... done
SamR1 commented

WORKERS_PROCESSES env variable is commented is the .env example... (with the default config, email sending is disabled).

can you uncomment this variable?

SamR1 commented

I reproduced the same issue (in my .env the variable was uncommented), my bad...

The variable must be exposed even the email and workers are disabled. I'll fix the .env example (and add some infos in README.md).

fr567 commented

Thank you very much for the debug session :-). I learned a litte bit more about docker and docker-compose.

Maybe one additonal point. I still got an error in the make migrate, because the authorization to the db was wrong. I had to change the passwort in .env for for the db-access also DATABASE_URL=postgresql://fittrackee:new_passwort_from_db/create.sql@fittrackee-db:5432/fittrackee

SamR1 commented

If you want to change fittrackee user password, you must also change it in the database creation script.

fr567 commented

Hi,

yes I changed it in db/create.sql like it is written in the install instructions. I was only not aware, that I also had to change something in .env.

THX for the help. Now it is working.

SamR1 commented

great! :)

and for postgres user, the password can be changed by modifying the env variables (before 1st install)

POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres

EDIT:
fix reply since variable are already in .env