Why does logster need a redis connection while building asset:precompile?

I have a ruby on rails 7 project.

To create my Docker containers, I use the default Dockerfile to create the image while running rails new.

The Dockerfile contains the instructions to compile assets:

RUN SECRET_KEY_BASE=`bundle exec rake secret` bundle exec rake assets:precompile

Since I added Logster into my Gemfile. I do have a lot of errors coming from this line because Logster cannot establish a connection with Redis.

For my part, this is the expected behavior because when building a Docker image, none of my services are running.

What can I do prevent the error from being shown or handled?

I did create a dummy Redis service which is added when running this single rake task in my application. This way I do not need a Redis connection and I do not have errors. However, I found my solution too hacky and I want to do it the right way.

Thank you for your help,