Seravo / wordpress

The WordPress project layout used by many of Seravo's customers, suitable also for local development with Vagrant and git deployment
https://seravo.com
GNU General Public License v3.0
104 stars 54 forks source link

Custom provisioning script #44

Closed k1sul1 closed 7 years ago

k1sul1 commented 7 years ago

Currently it seems that there's no way to run custom provisioning scripts (adding features such as local backups, maybe changing some settings etc) without modifying Vagrantfile directly.

I'm proposing a new feature to the Vagrantfile: check if a custom provisioning script (customize_vagrant.sh?) exists in the directory, and if it does, run it.

It should be fairly straightforward, add a few lines, including something like this config.vm.provision "shell", path: "customize_vagrant.sh" to this block of code.

anttiviljami commented 7 years ago

I like this idea. :+1:

ottok commented 7 years ago

Yes, good idea. Actually I know at least one use case already where this would solve a customer issue. Do you @k1sul1 happen to know any existing examples where this pattern is already used, so we could check what naming schemes to follow and any potential caveats etc?

k1sul1 commented 7 years ago

Can't think of any. I've never used VVV so can't say anything about it, and roots/trellis is a bit more complex than this.

Maybe the implementation could be similar to this? https://github.com/Seravo/wordpress/tree/master/nginx

Or certain parts of the Vagrantfile would call some file if it exists? We could create simple example scripts that the user could rename if they wanted to use it, just like config-sample.yml becomes config.yml.

That way it should work kinda like WordPress hooks, and users could build on that. I was thinking of making a "starter kit" like this, which would let me use the same build pipelines and project structures that I use in every project, and always start with the latest version of this repository:

wordpress-site/
  htdocs/wp-content/themes/skeleton
  vagrant_provision/
    complete.sh
  composer.json
  composer.lock
  start.sh
  package.json

(start.sh)

#!/bin/bash
mkdir temp
mv htdocs temp/
git clone git@github.com:Seravo/wordpress.git .
mv temp/htdocs ./htdocs
rmdir temp
rm -rf .git/ 
vagrant up
ottok commented 7 years ago

@k1sul1 What is it you want to customize in your script? VirtualBox settings? Make custom search-replace to the database? Give some examples so I know what use case this should server.

ottok commented 7 years ago

@k1sul1 Implemented now ae51719e146615e7fcbde6b69c8a1deeb386510e - is this usable for your needs?

k1sul1 commented 7 years ago

Should be.

My current use: I create a script that takes local database backups and runs every n minutes using cron, because Vagrant has proven itself to be quite volatile and no one remembers to take backups manually.

ottok commented 7 years ago

No further discussion, closing issue as ae51719 seems to have fixed this.