FitTrackee icon indicating copy to clipboard operation
FitTrackee copied to clipboard

[bug] The docker image in multi user configuration fails to start

Open Vertux opened this issue 6 months ago • 5 comments

Checklist

  • [x] Describe the bug.
  • [x] Copy of the output/log.
  • [x] Include your .env file.
  • [x] Steps to Reproduce
  • [x] The exact command that failed. This is what you typed at the command line, including any options.
  • [x] FitTrackee version, this is reported by pip show fittrackee
  • [x] Operating System and Python Version
  • [x] Installed Python packages

Describe the bug

If I run the default single user docker-compose.yaml everything works fine, but if I switch to the multi user configuration the services fails to start.

Copy of the output/log

# docker compose up
[+] Running 6/6
 ✔ Network fittrackee_external_network  Created                                                                                       0.1s
 ✔ Network fittrackee_internal_network  Created                                                                                       0.0s
 ✔ Container fittrackee-redis           Created                                                                                       0.1s
 ✔ Container fittrackee-db              Created                                                                                       0.1s
 ✔ Container fittrackee                 Created                                                                                       0.0s
 ✔ Container fittrackee-workers         Created                                                                                       0.0s
Attaching to fittrackee, fittrackee-db, fittrackee-redis, fittrackee-workers
fittrackee-redis    | Starting Redis Server
fittrackee-db       |
fittrackee-db       | PostgreSQL Database directory appears to contain a database; Skipping initialization
fittrackee-db       |
fittrackee-redis    | 1:C 25 Jun 2025 19:18:47.408 # WARNING Your system is configured to use the 'xen' clocksource which might lead to degraded performance. Check the result of the [slow-clocksource] system check: run 'redis-server --check-system' to check if the system's clocksource isn't degrading performance.
fittrackee-redis    | 1:C 25 Jun 2025 19:18:47.409 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
fittrackee-redis    | 1:C 25 Jun 2025 19:18:47.409 * Redis version=8.0.2, bits=64, commit=00000000, modified=1, pid=1, just started
fittrackee-redis    | 1:C 25 Jun 2025 19:18:47.409 * Configuration loaded
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.409 * monotonic clock: POSIX clock_gettime
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.411 * Running mode=standalone, port=6379.
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.414 * <bf> RedisBloom version 8.0.1 (Git=unknown)
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.414 * <bf> Registering configuration options: [
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.414 * <bf> 	{ bf-error-rate       :      0.01 }
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.415 * <bf> 	{ bf-initial-size     :       100 }
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.415 * <bf> 	{ bf-expansion-factor :         2 }
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.415 * <bf> 	{ cf-bucket-size      :         2 }
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.415 * <bf> 	{ cf-initial-size     :      1024 }
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.415 * <bf> 	{ cf-max-iterations   :        20 }
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.415 * <bf> 	{ cf-expansion-factor :         1 }
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.415 * <bf> 	{ cf-max-expansions   :        32 }
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.415 * <bf> ]
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.415 * Module 'bf' loaded from /usr/local/lib/redis/modules//redisbloom.so
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.428 * <search> Redis version found by RedisSearch : 8.0.2 - oss
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.429 * <search> RediSearch version 8.0.1 (Git=5688fcc)
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.429 * <search> Low level api version 1 initialized successfully
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.430 * <search> gc: ON, prefix min length: 2, min word length to stem: 4, prefix max expansions: 200, query timeout (ms): 500, timeout policy: return, cursor read size: 1000, cursor max idle (ms): 300000, max doctable size: 1000000, max number of search results:  1000000,
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.430 * <search> Initialized thread pools!
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.430 * <search> Disabled workers threadpool of size 0
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.431 * <search> Subscribe to config changes
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.431 * <search> Enabled role change notification
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.432 * <search> Cluster configuration: AUTO partitions, type: 0, coordinator timeout: 0ms
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.433 * <search> Register write commands
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.433 * Module 'search' loaded from /usr/local/lib/redis/modules//redisearch.so
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.440 * <timeseries> RedisTimeSeries version 80001, git_sha=577bfa8b5909e7ee572f0b651399be8303dc6641
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.440 * <timeseries> Redis version found by RedisTimeSeries : 8.0.2 - oss
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.440 * <timeseries> Registering configuration options: [
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.440 * <timeseries> 	{ ts-compaction-policy   :              }
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.440 * <timeseries> 	{ ts-num-threads         :            3 }
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.440 * <timeseries> 	{ ts-retention-policy    :            0 }
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.440 * <timeseries> 	{ ts-duplicate-policy    :        block }
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.440 * <timeseries> 	{ ts-chunk-size-bytes    :         4096 }
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.440 * <timeseries> 	{ ts-encoding            :   compressed }
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.440 * <timeseries> 	{ ts-ignore-max-time-diff:            0 }
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.440 * <timeseries> 	{ ts-ignore-max-val-diff :     0.000000 }
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.440 * <timeseries> ]
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.442 * <timeseries> Detected redis oss
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.442 * Module 'timeseries' loaded from /usr/local/lib/redis/modules//redistimeseries.so
fittrackee-db       | 2025-06-25 19:18:47.582 UTC [1] LOG:  starting PostgreSQL 17.5 on x86_64-pc-linux-musl, compiled by gcc (Alpine 14.2.0) 14.2.0, 64-bit
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.461 * <ReJSON> Created new data type 'ReJSON-RL'
fittrackee-db       | 2025-06-25 19:18:47.583 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.468 * <ReJSON> version: 80001 git sha: unknown branch: unknown
fittrackee-db       | 2025-06-25 19:18:47.583 UTC [1] LOG:  listening on IPv6 address "::", port 5432
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.468 * <ReJSON> Exported RedisJSON_V1 API
fittrackee-db       | 2025-06-25 19:18:47.595 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.468 * <ReJSON> Exported RedisJSON_V2 API
fittrackee-db       | 2025-06-25 19:18:47.615 UTC [30] LOG:  database system was shut down at 2025-06-25 19:17:56 UTC
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.468 * <ReJSON> Exported RedisJSON_V3 API
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.468 * <ReJSON> Exported RedisJSON_V4 API
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.468 * <ReJSON> Exported RedisJSON_V5 API
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.468 * <ReJSON> Enabled diskless replication
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.470 * <ReJSON> Initialized shared string cache, thread safe: false.
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.470 * Module 'ReJSON' loaded from /usr/local/lib/redis/modules//rejson.so
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.470 * <search> Acquired RedisJSON_V5 API
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.471 * Server initialized
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.477 * <search> Loading event starts
fittrackee-db       | 2025-06-25 19:18:47.650 UTC [1] LOG:  database system is ready to accept connections
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.477 * <search> Enabled workers threadpool of size 4
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.478 * Loading RDB produced by version 8.0.2
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.478 * RDB age 52 seconds
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.478 * RDB memory usage when created 1.12 Mb
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.478 * Done loading RDB, keys loaded: 1, keys expired: 0.
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.478 * <search> Disabled workers threadpool of size 4
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.478 * <search> Loading event ends
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.478 * DB loaded from disk: 0.005 seconds
fittrackee-redis    | 1:M 25 Jun 2025 19:18:47.479 * Ready to accept connections tcp
fittrackee          | Upgrading database...
fittrackee          | INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
fittrackee          | INFO  [alembic.runtime.migration] Will assume transactional DDL.
fittrackee          | Running app...
Gracefully stopping... (press Ctrl+C again to force)
dependency failed to start: container fittrackee is unhealthy

Include the .env file

# Custom variables initialisation
# Docker volumes
# export UPLOAD_DIR=
# export LOG_DIR=
# export DATABASE_DIR=
# export REDIS_DIR=

# Application
export FLASK_APP=fittrackee
export FLASK_SKIP_DOTENV=1
# export APP_PORT=5000
export APP_SECRET_KEY='secret'
export APP_LOG=/usr/src/app/logs/fittrackee.log
export APP_WORKERS=2
# export APP_TIMEOUT=30

# export UPLOAD_FOLDER=/usr/src/app/uploads
# export STATICMAP_CACHE_DIR=/usr/src/app/.staticmap_cache

# PostgreSQL
export POSTGRES_USER=fittrackee
export POSTGRES_PASSWORD=secret
export POSTGRES_DB=fittrackee
export DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@fittrackee-db:5432/${POSTGRES_DB}

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

# API rate limits
# export API_RATE_LIMITS="300 per 5 minutes"

# Dramatiq Tasks (for user data export and email sending)
# export TASKS_TIME_LIMIT=1800  # 30 minutes

# Emails
export UI_URL=https://fittrackee.test.com
#export EMAIL_URL=smtp://[email protected]:[email protected]:465/?ssl=True
#export [email protected]

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

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

To Reproduce

docker compose up

FitTrackee Version

FitTrackee v0.10.3

Python Version

3.12

FitTrackee installation method

With Docker image

Operating System

GNU/Linux

Python Packages

Docker image under Linux dock 6.15.3-100.fc41.x86_64 (Fedora Server v41)

Vertux avatar Jun 25 '25 19:06 Vertux

Hi,

are there any errors in the log files? does docker-compose.yml contain any additional modifications to the example in the repository?

SamR1 avatar Jun 26 '25 06:06 SamR1

Hi,

are there any errors in the log files? does docker-compose.yml contain any additional modifications to the example in the repository?

I cannot see any errors in the logs, only: 2025/06/26 18:13:56 - fittrackee - WARNING - EMAIL_URL is not provided, email sending is deactivated. But I don't think that should be a problem. When I tried it for the first time, I added the EMAIL_URL, but it made no difference.

I did only one adaptation in the docker-compose.yaml I added these lines:

  fittrackee:
    container_name: fittrackee
    env_file:
      - .env
    image: fittrackee/fittrackee:latest
    # Added
    environment:
      DISABLE_REGISTRATION: true

Vertux avatar Jun 26 '25 18:06 Vertux

If EMAIL_URL is not set, it only deactivates email sending, but the application starts normally.

Disabling registration is not done via an environment variable, but by setting the limit on active users in the application administration.

For the moment, I didn't manage to reproduce the issue on fresh install (with Docker version 28.1.1 and Docker Compose version 2.36.0). With the same .env, the containers appear healthy and the only issue I had is error on upload due to the following commented variables:

# export UPLOAD_FOLDER=/usr/src/app/uploads
# export STATICMAP_CACHE_DIR=/usr/src/app/.staticmap_cache

docker-compose.yml:

services:
  fittrackee-db:
    container_name: fittrackee-db
    image: postgres:17-alpine
    env_file:
      - .env
    volumes:
      - ${DATABASE_DIR:-./data/db}:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
      interval: 5s
      timeout: 15s
      retries: 3
    networks:
      - internal_network
    restart: unless-stopped

  fittrackee:
    container_name: fittrackee
    env_file:
      - .env
    image: fittrackee/fittrackee:v0.10.3
    volumes:
      - ${UPLOAD_DIR:-./data/uploads}:/usr/src/app/uploads
      - ${LOG_DIR:-./data/logs}:/usr/src/app/logs
      - ${STATICMAP_CACHE_DIR:-./data/staticmap_cache}:/usr/src/app/.staticmap_cache
    post_start:
      - command: chown -R fittrackee:fittrackee /usr/src/app/uploads /usr/src/app/logs /usr/src/app/.staticmap_cache
        user: root
    ports:
      - "${APP_PORT:-5000}:5000"
    command: 'sh docker-entrypoint.sh'
    depends_on:
      fittrackee-db:
        condition: service_healthy
      fittrackee-redis:
        condition: service_healthy
    healthcheck:
      test: ["CMD-SHELL", "wget --spider http://127.0.0.1:5000/api/ping || exit 1"]
      interval: 5s
      timeout: 15s
      retries: 3
    networks:
      - external_network
      - internal_network
    restart: unless-stopped

  fittrackee-workers:
    container_name: fittrackee-workers
    env_file:
      - .env
    image: fittrackee/fittrackee:v0.10.3
    volumes:
      - ${UPLOAD_DIR:-./data/uploads}:/usr/src/app/uploads
      - ${LOG_DIR:-./data/logs}:/usr/src/app/logs
      - ${STATICMAP_CACHE_DIR:-./data/staticmap_cache}:/usr/src/app/.staticmap_cache
    post_start:
      - command: chown -R fittrackee:fittrackee /usr/src/app/uploads /usr/src/app/logs /usr/src/app/.staticmap_cache
        user: root
    command: "dramatiq fittrackee.tasks:broker --processes=2 --log-file=/usr/src/app/logs/dramatiq.log"
    depends_on:
      fittrackee:
        condition: service_healthy
    networks:
      - internal_network
      - external_network
    restart: unless-stopped

  fittrackee-redis:
    image: "redis:8.0"
    container_name: fittrackee-redis
    hostname: redis
    volumes:
      - ${REDIS_DIR:-./data/redis}:/data
    healthcheck:
      test: ['CMD', 'redis-cli', 'ping']
    networks:
      - internal_network
    restart: unless-stopped

networks:
  external_network:
  internal_network:
    internal: true

Is it possible to re-install from scratch with the following modifications:

  • uncomment UPLOAD_FOLDER and STATICMAP_CACHE_DIR in .env
  • use fittrackee/fittrackee:v0.10.3 instead of fittrackee/fittrackee:latest as image, in case a previous version tagged as latest has been downloaded before?

SamR1 avatar Jun 28 '25 06:06 SamR1

@SamR1 I did a reinstall from scratch, but I ended up with the same error. I forgot to point out that I only use docker rootless for security reasons. For this reason, I also had to adjust the paths for UPLOAD_FOLDER and STATICMAP_CACHE_DIR. It looks like the docker image cannot be used rootless.

EDIT: With a normal docker environment (root) everything works fine.

Vertux avatar Jun 28 '25 15:06 Vertux

Thanks for the info, I'll see if I can build a rootless image.

SamR1 avatar Jun 30 '25 05:06 SamR1