sinnbeck / laravel-served

Docker version of artisan serve (with alot more)
MIT License
74 stars 13 forks source link

"cache" name #15

Open sinnbeck opened 3 years ago

sinnbeck commented 3 years ago

"cache" served name to enable clean up of old containers and images on name change

ri5h commented 3 years ago

Hello @sinnbeck I would like to work on this, I have some experience working with docker and laravel. Can you provide more details about this issue, for example:

  1. How to reproduce this ?
  2. How to test it?
  3. Or anything else in general will be very helpful. Thanks
sinnbeck commented 3 years ago

@rishirajpurohit Sounds good.

  1. Currently we create image and container names using one of two methods. If a name is set in the served.php config file, we use that, and if not we use the folder name (slug). Now if you build and start your containers it will create them for you with names like served_{your_name}_web. Now suppose you deside to change the name, and just rebuild the images/containers. You will now be left with trailing images/containers that are no longer used. You can of course prune these yourself, but the point of this package is to do the hard work for you (you dont need to learn docker to use it).
  2. I dont have any experience testing docker directly and I am unsure if it is a good idea. But it should easy to test if some file exists, and then ensure that a cleanup command is run before building.
  3. I was thinking perhaps a cached version of the config perhaps? Kinda like php artisan config:cache does it. And we can use that to compare. But it could as a start also just be a simple file containing the last used name.

In theory you could build and run a memcahed (example) container and then deside to switch to redis, and then expect that the package would clean this for you. (this would require that we cache the entire last used config)

sinnbeck commented 3 years ago

You can easily try it out by running these two commands (you can run them twice where you change the name in between runs)


php artisan served:up
php artisan served:list
ri5h commented 3 years ago

Thank you for the details, I will try it out tonight and then see how I can start working on this issue