geerlingguy / drupal-container

Drupal container for running Drupal sites with Docker, built with Ansible.
https://hub.docker.com/r/geerlingguy/drupal/
44 stars 27 forks source link

Add automatic install in entrypoint if DRUPAL_INSTALL_IF_NOT_INSTALLED true #7

Open geerlingguy opened 5 years ago

geerlingguy commented 5 years ago

I never really completed https://github.com/geerlingguy/drupal-container/issues/1 ... I want to make it so, if there are database credentials provided, and an env variable like DRUPAL_INSTALL_IF_NOT_PRESENT is true, then we use Drush to install Drupal... maybe?

Basically, it would take another step out of the first-use/testing order of operations for this image. Mostly, I'm thinking of how it relates to the Raspberry Pi Dramble. Right now after setting everything up, you have to run through the Drupal installer via UI to complete the Drupal installation.

Not that that's horrible or anything, it just takes a little extra time, and isn't automatic. I hate things that aren't automatic.

If Drupal is already installed (or DRUPAL_INSTALL_IF_NOT_INSTALLED is set to false), then this new code that does the installation should not be run.

geerlingguy commented 5 years ago

Note that this can have interesting results if it's in an environment with multiple replicas. See: https://github.com/geerlingguy/raspberry-pi-dramble/issues/139

It's fine for testing / evaluation purposes... but you really need a dynamic/environment-variable-driven settings.php file if you want to scale to more than one pod/container.

geerlingguy commented 5 years ago

In the Kubernetes world, it might be possible to avoid conflict using an initContainer.

In that container, check if Drupal is installed. If so, exit. If not, run the install then exit.