dergachev / vagrant-drupal

Example of integration of Vagrant, deploy-drupal cookbook, and your Drupal project.
8 stars 3 forks source link

Vagrant Drupal Template

This repo exists to suggest a template for organizing your new or existing Drupal project repo, to be compatible with the deploy-drupal cookbook. By following our suggestions, you will have a complete workflow for quickly getting a Vagrant VM that's ready to serve your as your complete dev environment, including:

Setup

This guide will cover the workflow around 3 main cases:

Deploying a fresh Drupal install

For this case, there is nothing to do. Simply run vagrant up and the deploy-drupal cookbook will download the latest stable version of D7, and run drush site-install for to populate a clean Drupal database.

If you don't customize the settings in Vagrantfile, then:

Creating project repo

After the initial deployment, it's recommended to commit the newly created site to a newly-created git repo, as follows:

vagrant ssh
cd /var/shared/sites/cooked.drupal

# make a backup of the site
drush --root='/var/shared/sites/cooked.drupal/site' sql-dump --gzip --result-file='../db/dump.sql.gz'

# clean up: remove README.md, etc.

echo "settings-priv.php sites/default/files" | tr ' ' '\n' >> .gitignore
git init
git add .
git commit -m "Fresh Drupal site created by deploy-drupal cookbook"

# create a new repo, say at github

git remote add origin https://github.com/USERNAME/NEWREPO.git
git push -u origin master

At this point, we recommend to blow away PROJECTROOT on the host, and recreate it from the NEWREPO.git, which can be done as follows:

# exit vagrant ssh
git remote set-url upstream https://github.com/USERNAME/NEWREPO.git
git pull # this will auto-merge your repo
git push -u origin master # pushes vagrant-chef commits (including this README.md) to your new repo

Now simply redeploy the Drupal dev environment from the new Drupal repository:

# alternative: RESET_DRUPAL=1 vagrant provision
vagrant destroy # be sure you committed and pushed all your code & db!
vagrant up

Deploying from existing project repo

At this point we assume you have cloned a Drupal project repository, contianing a Drupal codebase, SQL dump, and suitable Vagrantfile and Berksfile configurations. Note that the default Vagrantfile contains the following configuration for the deploy-drupal cookbook:

'drupal-deploy' => { 
  'sql_load_file' => '/vagrant/db/dump.sql.gz', # if non-existant, DB will be initialized via 'drush si'
  'codebase_source_path' =>  '/vagrant/site', # if folder is empty, will download D7 instead
},

Adjust these as needed, then simply run vagrant up to do the following:

At this point,

Installation

These are a few pre-requisites to install:

Warning

There are currently serious problems with deploy-drupal and git:

Hacking on the deploy-drupal cookbook

To hack on the deploy-drupal cookbook, fork https://github.com/amirkdv/chef-deploy-drupal, then do the following:

mkdir site-cookbooks
git clone https://github.com/USERNAME/chef-deploy-drupal.git site-cookbooks/deploy-drupal
vim Berksfile # uncomment the following line:   cookbook 'deploy-drupal', :path => 'site-cookbooks/deploy-drupal'