Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Developing in Docker but cache connection required during package discovery process #828

Closed
danvim opened this issue Feb 16, 2020 · 9 comments

Comments

@danvim
Copy link

danvim commented Feb 16, 2020

  • Telescope Version: 2.1.3
  • Laravel Version: 6.9.0
  • PHP Version: 7.4

Description:

This issue has been raised before #620. But the resolution was really a work around at that point. I wanted to bring the issue forth once more.

I'm using Docker Compose as a development and production environment. And previously, "Disabling telescope for builds seems a reasonable solution." does not work in my case.

My Docker Compose file includes the following:

  • Laravel application built using a Dockerfile that includes compose install
  • DB
  • Redis, exposing internal endpoint my_redis:6379
  • Nginx

The problem arises when a new developer tries to clone the project, setup the development environment and build everything fresh. During Docker's build process, Telescope tries to connect to the endpoint my_redis:6379, which isn't up yet, thus fails to build. So, Docker Compose cannot up any containers, (including Redis).

I wanted Telescope to work in my local development environment in Docker Compose. My current mitigation method is to add --no-scripts to composer install during my Docker build, and instead, run composer dumpautoload when the container starts.

For my case, it doesn't make sense to disable Telescope. My current mitigation method has a slow container start time. Is there anyway this problem can be fixed one way or another?

I've made a StackOverflow issue a while ago: https://stackoverflow.com/questions/59810019/dockerfile-build-laravel-trying-to-connect-to-redis-service-yet-to-up My example docker-compose.yml is here.

Steps To Reproduce:

  1. Setup Docker Compose file and add the Laravel service built with a custom Dockerfile that includes compose install. Add Redis service with name my_redis.
  2. Require Telescope in the Laravel application.
  3. Setup to use Redis in .env for cache/queue/etc, and setup REDIS_HOST to be the Docker Compose service endpoint, e.g. my_redis
  4. Enable Telescope.
  5. Run docker-compose build in this fresh project.
@kohlerdominik
Copy link
Contributor

kohlerdominik commented Mar 19, 2020

  • Telescope Version: 3.2.0
  • Laravel Version: 7.2.0
  • PHP Version: 7.3

We can confirm a similar issue. That the cache connection is required is a big drawback for using Telescope.

In addition to the initial description

It’s not possible to run any command, not even artisan help, without having the redis instance up and running.
Especially, it’s not possible to run artisan package:discover, which is automatically triggered by composer install.

The issue in our use case

Beside of the initial raised issue description, there is an additional use case: If a builder container is used, based on hub.docker.com/_/composer for example, it’s usually not the case to have the redis dependency set up nor to have ext-redis installed (except if it’s added in a custom build, which just increases container overhead without actual benefit).

Steps to reproduce

  1. Clone a fresh Laravel installation git clone https://github.com/laravel/laravel.git
  2. Prepare a simple .env file:
    • cp .env.example .env
    • Change CACHE_DRIVER to redis
  3. Add laravel as required "laravel/telescope": "^3.1",composer.json
  4. Run the original composer container to install dependencies:
    docker run --rm --interactive --tty --volume $PWD:/app composer install --ignore-platform-reqs

@themsaid themsaid removed their assignment Mar 25, 2020
@driesvints
Copy link
Member

Hello everyone. Since a majority of developers aren't experiencing this particularly issue it's hard to focus our attention to solving this (more so because we're not using Docker ourselves). If you want to get Telescope to work better with Docker we're welcoming prs. Thanks for raising this.

@eldair
Copy link

eldair commented Aug 3, 2020

Same issue here
In short, the package is attempting to connect to redis during package discovery process
Also, can we disable it when running tinker command?

@agustinprod
Copy link

It's just not a docker problem, you can have the issue anywhere where you don't have a redis service running. The problem it's the discover will touch the cache, you can fix this by settings the .env with:

CACHE_DRIVER=file

I'm doing this in a step before running composer install and resetting it after all artisan commands run.

@lopezdonaque
Copy link

Same error here.
The problem is due to the DumpWatcher.
Disabling it will fix the error.
I think it should not be executed during the package:discover.

if (! $this->cache->get('telescope:dump-watcher')) { return; }

Watchers\DumpWatcher::class => env('TELESCOPE_DUMP_WATCHER', false),

@danvim
Copy link
Author

danvim commented Feb 4, 2021

It's just not a docker problem, you can have the issue anywhere where you don't have a redis service running. The problem it's the discover will touch the cache, you can fix this by settings the .env with:

CACHE_DRIVER=file

I'm doing this in a step before running composer install and resetting it after all artisan commands run.

I would argue it is normally not an issue since nobody would realistically run telescope without their cache instance running. Therefore, my aim of this issue was to ask for a feature to turn off connection requirement (with or without a special option) during package discovery.

@screw
Copy link

screw commented Feb 4, 2022

Same error here. The problem is due to the DumpWatcher. Disabling it will fix the error. I think it should not be executed during the package:discover.

if (! $this->cache->get('telescope:dump-watcher')) { return; }

Watchers\DumpWatcher::class => env('TELESCOPE_DUMP_WATCHER', false),

Where do you put this code?

@jaketoolson
Copy link

@screw - This goes in your telescope config file.

@NilLlisterri
Copy link

NilLlisterri commented Mar 26, 2024

In our case, the best solution has also been disabling the dump watcher in the telescope config file (config/telescope.php), as we were filtering those entries anyway.

Watchers\DumpWatcher::class => [
    'enabled' => env('TELESCOPE_DUMP_WATCHER', false),
    'always' => env('TELESCOPE_DUMP_WATCHER_ALWAYS', false),
],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants