Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Build and push Drupal VM base box to Vagrant Cloud, and use it as default #1774

Closed
7 tasks done
geerlingguy opened this issue May 16, 2018 · 15 comments
Closed
7 tasks done

Comments

@geerlingguy
Copy link
Owner

geerlingguy commented May 16, 2018

Issue Type

  • Feature Idea

Summary

I've considered doing this in the past a few times, but a few people have been asking me about it again recently. Basically, there's already beet/box, which is kind of a 'Drupal VM plus' base box for Vagrant/VirtualBox.

But it would help with provisioning speed for the great majority of Drupal VM users (as long as they're using Ubuntu 16.04 or whatever's the current default OS) to have an official geerlingguy/drupal-vm base box which is basically all the current defaults from default.config.yml.

And if I set that up using Packer... I could also set up an Amazon AMI build so those using cloud dev environments (e.g. with Cloud9 could quickly spin up a Drupal VM instance in the cloud and hack on a Drupal site easily. Every time I travel I'm reminded of some of the major benefits of such an environment—imagine doing a super speedy composer install or composer update on your Drupal site while you're flying and have like 2 Kbps of bandwidth!

Anyways, I'm opening this issue to mull this over. I don't know if I'll do it or not yet, but I'm leaning towards spending an hour or two on at least seeing if I can make it automated enough with Vagrant Cloud/Atlas so it's no additional maintenance burden (besides maybe clicking a button) on myself.

TODO

  • Create open source Drupal VM packer build project (see: https://github.com/geerlingguy/packer-drupal-vm)
  • Build and push up Drupal VM Base Box to Vagrant Cloud (see: https://app.vagrantup.com/geerlingguy/boxes/drupal-vm)
  • Switch default base box in default.config.yml
  • Add docs on docs.drupalvm.com for "Building your own Drupal VM base box"
  • Add tasks to switch off default services which can be toggled:
    • MySQL - if set to postgresql, stop mysql and disable on boot
    • Apache - if set to nginx, stop apache2/httpd and disable on boot
@geerlingguy
Copy link
Owner Author

Testing things out locally... https://app.vagrantup.com/geerlingguy/boxes/drupal-vm

@geerlingguy
Copy link
Owner Author

geerlingguy commented May 18, 2018

And there's a version 1.0.0 now; I'm testing with vagrant_box: geerlingguy/drupal-vm now... some stats:

  • geerlingguy/drupal-vm:
    • Cold start: 00:07:19 to provision, box size 996 MB
    • Warm start: 00:04:30 to provision
  • geerlingguy/ubuntu1604:
    • Cold start: 00:08:16 to provision, box size 797 MB
    • Warm start: 00:06:12 to provision

In both cases, the provisioning was 'cold', with neither the base box nor the linked clone already set up locally (the box had to be downloaded and the initial VM had to be started).

@geerlingguy
Copy link
Owner Author

And the code: https://github.com/geerlingguy/packer-drupal-vm

@geerlingguy
Copy link
Owner Author

One issue with doing this: if someone has:

drupalvm_webserver: nginx

...then the vagrant up or provision fails with:

TASK [geerlingguy.nginx : Ensure nginx is started and enabled to start at boot.] ***
fatal: [drupalvm]: FAILED! => changed=false 
  msg: |-
    Unable to start service nginx: Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

This is because the default box has already set up Apache 2.4 and it's running on port 80, blocking Nginx from doing the same.

So... before thinking about switching to using an optimized base box by default instead of the minimal Ubuntu install, we'd need to solve this problem (and also make sure none of the other config changes would break things—e.g. what if the user has drupal_db_backend: pgsql?).

@thom8
Copy link
Collaborator

thom8 commented May 23, 2018

Keen to help out on this and potentially decommission beetbox :)

We've run into a major problem as Hashicorp are shutting down Atlas Cloud :(

The Packer, Artifact Registry and Terraform Enterprise (Legacy) features of Atlas will 
no longer be actively developed or maintained and will be fully decommissioned 
on Thursday, May 31, 2018

RE: nginx - we had this issue too and resolved it by running them on different ports -- https://github.com/beetboxvm/beetbox/blob/master/provisioning/ansible/config/default.config.yml#L59

@geerlingguy
Copy link
Owner Author

Wait what?!

@geerlingguy
Copy link
Owner Author

Vagrant Cloud will still exist, right? https://www.vagrantup.com/docs/vagrant-cloud/

@thom8
Copy link
Collaborator

thom8 commented May 23, 2018

Yep, it's the packer cloud service that is being decommissioned.

They reference this page to migrate to a CI builder -- https://www.packer.io/guides/packer-on-cicd/

Problem is you can build a virtualbox image on travis / circle :(

@geerlingguy
Copy link
Owner Author

Ah, I see. I build the boxes locally and push the images up to Vagrant Cloud, so I think I'm safe for now. I've thought about spinning up a Jenkins VM on a Mac mini I have laying around, and doing CI builds for all the boxes... but I've also been lazy with doing that :P

@thom8
Copy link
Collaborator

thom8 commented May 23, 2018

Looks like that will be the way to go from next week... beetbox is relying on packer push.

https://www.packer.io/docs/commands/push.html

@iijiang
Copy link

iijiang commented Jun 25, 2018

I had this warning coming up since the first time was running apache. I did ssh into drupal-vm, run:
sudo service apache2 stop

Redo the provision, seems the warning is gone.

@geerlingguy
Copy link
Owner Author

@iijiang - Yeah, that should work... it might be best to add a simple Drupal VM command though to at least stop/disable Apache if Nginx is detected as the selected webserver. I'm kind of working on this alongside Ubuntu 18.04 support.

I have to provision and reprovision a site like 40 times this week, and I want faster cold start times :D

@geerlingguy
Copy link
Owner Author

Moving work from #1126 into this ticket—will make a checklist in the OP.

@geerlingguy geerlingguy changed the title Build and push Drupal VM Amazon AMI and VirtualBox image? Build and push Drupal VM base box to Vagrant Cloud, and use it as default Nov 21, 2018
@geerlingguy
Copy link
Owner Author

geerlingguy commented Nov 21, 2018

Testing with a pretty vanilla Acquia BLT project:

Base box Time (cold start) Time (box already dl'ed) Things changed
geerlingguy/ubuntu1604 00:08:41 00:07:54 120
geerlingguy/drupal-vm 00:06:32 00:04:56 40
speedup ~30% faster ~60% faster -

Note that in the interest of me not wasting my entire life testing, I only ran the tests once. But it's a pretty huge difference as most tasks fly through as 'OK'.

@geerlingguy
Copy link
Owner Author

Marking as fixed. Makes me happy.

I'm sure there will be a few cleanup issues, and maybe we'll want to not install any extras by default to make the base base box be a little more trim... but happy otherwise!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants