ddev / ddev-redis

Redis service for DDEV
Apache License 2.0
21 stars 8 forks source link

Provide Drupal or other settings for redis #2

Closed rfay closed 1 year ago

rfay commented 2 years ago

On Twitter you mentioned the idea of providing Drupal settings.

It would be possible for the post_install_actions to do something that reached out of .ddev.

For example,

post_install_actions:
-  if [ ${DDEV_PROJECT_TYPE} = "drupal9" ] then echo "some config" > $DDEV_APPROOT/$DDEV_DOCROOT/sites/default/settings.redis.php; fi
- echo "Sample Drupal redis configuration has been placed in sites/default/settings.redis.php if you want to include it from settings.php"

Maybe that's worth a try?

hussainweb commented 2 years ago

That sounds great. Is there an environment variable that stores the project directory? I don't think it runs in the project directory because I was not able to refer to relative paths in some of the tests. The idea is that I would have a settings.redis.php and just copy the file if it is Drupal.

Alternatively, I could just copy the file to within the .ddev directory and then modify the settings.php to include that. Thoughts on this?

rfay commented 2 years ago

As in the example. $DDEV_APPROOT. See the first set (host-side) of environment variables in https://ddev.readthedocs.io/en/latest/users/extend/custom-commands/#environment-variables-provided

rfay commented 2 years ago

I think putting the file in .ddev should be fine. Really I wish settings.ddev.php lived there.

rfay commented 2 years ago

The one thing to remember for sure though: Unless this is a drupal-specific recipe, it needs to not do things that other CMSs will find objectionable.

hussainweb commented 2 years ago

@rfay, agreed. In fact, I was exploring the idea of creating another addon specific to Drupal. But I think this is a simple enough conditional. I'll also check on how to not even copy the file if the recipe is not Drupal.

That brings me to a question: can I call a shell script directly from post_install_actions? I suppose I can but the question is how do I get a path of a file I am not copying to .ddev directory.

rfay commented 2 years ago

Yes, that's exactly what you call there. See https://github.com/drud/ddev-drupal9-solr/blob/fcb7de120f937d818cb58a50c0b56e44cb146732/install.yaml#L12 for example.

hussainweb commented 2 years ago

@rfay, can you review this change?

I eventually copied the file to the settings directory as I couldn't figure out how to get the location of the .ddev directory from settings.php. I see DDEV_APPROOT environment variable is not listed under the container scripts section and if that is the host path, then we can use it within the container. I couldn't find out another simpler way to determine this. I wanted to avoid the dirname('../../..') trick for this because then I would have to factor in the web root.

rfay commented 2 years ago

I didn't try it out, but it looks good. Location of .ddev dir (on host) should be $DDEV_APPROOT/.ddev. In container, should be /var/www/html/.ddev

hussainweb commented 2 years ago

Thanks @rfay. I noticed a few problems and so going to move this to a PR.

hussainweb commented 2 years ago

@rfay, a question: would you still prefer the redis settings file to be within the .ddev directory? Or is it better it gets copied to be in the same directory as settings.ddev.php?

rfay commented 2 years ago

I'm fine with it either way. Probably since settings.ddev.php has been (wrongly) in sites/default for so many years it's fine to put it in there.

joelpittet commented 2 years ago

Thanks for adding the settings, that is a great way to get bootstrapped up. Could it also respect the disable_settings_management flag?

rfay commented 2 years ago

Wow, @joelpittet - this is a really old issue. Could you please open a new issue and give context for your request? Probably a PR would be fine also.

joelpittet commented 2 years ago

@rfay Yes for sure https://github.com/drud/ddev-redis/issues/6

rfay commented 1 year ago

This was completed in