More Related Content Similar to Vagrant for real codemotion (moar tips! ;-)) (20) More from Michele Orselli (20) Vagrant for real codemotion (moar tips! ;-))24. As rule of thumb you could assign the half cpus and
a quarter of the memory based on your host machine
https://stefanwrobel.com/how-to-make-vagrant-performance-not-suck
28. config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm",:id, "--memory", CONF["ram"]]
vb.customize ["modifyvm",:id, "--cpus", CONF["cpus"]]
end
config.vm.provider "vmware_fusion" do |v|
v.vmx["memsize"] = CONF["ram"]
v.vmx["numvcpus"] = CONF["cpus"]
end
37. config.vm.define "web" do |web|
web.vm.network :private_network, ip: "10.0.0.2"
web.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--memory", 2048]
end
web.vm.synced_folder "../", “/var/www"
end
config.vm.define "db" do |db|
db.vm.network :private_network, ip: "10.0.0.3"
db.vm.provision :shell, :path => 'vagrant/db.sh'
end
56. Default provider: virtualbox
3 PHP test suites with unit, functional, integration mix
small (sf1): build runs in ~25 sec
medium (zf2): build runs in ~2 mins
large (sf2): build runs ~ 20 mins
58. class AppKernel extends Kernel
{
public function getCacheDir()
{
if (in_array($this->environment, array('dev', 'test')))
{
return '/dev/shm/appname/cache/' . $this->environment;
}
return parent::getCacheDir();
}
public function getLogDir()
{
if (in_array($this->environment, array('dev', ‘test')))
{
return '/dev/shm/appname/logs';
}
return parent::getLogDir();
}
}
59. class AppKernel extends Kernel
{
public function getCacheDir()
{
if (in_array($this->environment, array('dev', 'test')))
{
return '/dev/shm/appname/cache/' . $this->environment;
}
return parent::getCacheDir();
}
public function getLogDir()
{
if (in_array($this->environment, array('dev', ‘test')))
{
return '/dev/shm/appname/logs';
}
return parent::getLogDir();
}
}
64. I/O: move DB on RAM
if you use sqlite move it on /dev/shm
69. - name: Install cachefilesd
apt: pkg=cachefilesd state=present
- name: Enable cachefilesd
lineinfile: dest=/etc/default/cachefilesd
line=“RUN=yes”
- name: Start cachefilesd service
service: name=cachefilesd state=restarted
76. - name: add mysql user
mysql_user: name=ideato
host='%'
password=ideato
priv=*.*:ALL,GRANT
login_user=root
login_password=
- name: config bind address to allow remote remote
connections
lineinfile: dest=/etc/mysql/my.cnf
state=present
regexp='bind-address = 127.0.0.1'
line='bind-address = 0.0.0.0'
backup=yes
- name: restart mysql
service: name=mysql state=restarted
77. - name: Install phpmyadmin
apt: pkg=phpmyadmin state=present
- name: Include phpmyadmin in Apache config
lineinfile: dest=/etc/apache2/apache2.conf
line="Include /etc/phpmyadmin apache.conf"
notify: restart apache
78. - name: adminer clone
git: repo=https://github.com/vrana/adminer.git
dest=/var/www/adminer
version=v4.2.1
accept_hostkey=true
- name: adminer compile
command: php compile.php
chdir=/var/www/adminer
creates=/var/www/adminer/adminer-4.2.1.php
88. quick and easy way to start
they’re general
old platforms are not supported
a lot of a good ideas you can steal from
89. if which('ansible-playbook')
config.vm.provision "ansible" do |ansible|
ansible.playbook = "ansible/playbook.yml"
ansible.inventory_path = "ansible/inventories/dev"
ansible.limit = 'all'
ansible.extra_vars = {
private_interface: "192.168.33.99",
hostname: "default"
}
end
else
config.vm.provision :shell,
path: "ansible/windows.sh", args: ["default"]
end
91. if which('ansible-playbook')
config.vm.provision "ansible" do |ansible|
ansible.playbook = "ansible/playbook.yml"
ansible.inventory_path = "ansible/inventories/dev"
ansible.limit = 'all'
ansible.extra_vars = {
private_interface: "192.168.33.99",
hostname: "default"
}
end
else
config.vm.provision :shell,
path: "ansible/windows.sh", args: ["default"]
end
95. create your own template
https://github.com/ideatosrl/vagrant-php-template
96. you’re in control of provisioning command
you can perform additional checks on
host machine
99. live on the edge and fix provision script
use stable package repositories
102. vagrant package - -name mybox.box
publish it somewhere (http, atlas)
c.vm.box_url = “http://../mybox.box”