DeepK7 / magento2-fast-vm

Optimal vagrant developer box for Magento2. Folders synced by nfs/rsync. This box includes Magento developer utilities.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fast Virtual Machine for Magento2

vagrant dev-box mount release license

windows apple linux

image    image    image    image    image

associate-developer

Requirements

Virtualbox

VirtualBox is an open source virtualizer, an application that can run an entire operating system within its own virtual machine.
Stable version >= 5.2.0

  1. Download the installer for your laptop operating system using the links below.
  2. Run the installer, choosing all of the default options.
    • Windows: Grant the installer access every time you receive a security prompt.
    • Mac: Enter your admin password.
    • Linux: Enter your user password if prompted.
  3. Reboot your laptop if prompted to do so when installation completes.
  4. Close the VirtualBox window if it pops up at the end of the install.

Vagrant

Vagrant is an open source command line utility for managing reproducible developer environments.
Stable version >= 2.2.0

  1. Download the installer for your laptop operating system using the links below.
  2. Reboot your laptop if prompted to do so when installation completes.

Configurations

Related guide

Pre-installation

⚠ DO NOT USE SSH KEY WITH PASSPHRASE, this vagrant installation is non-interactive.
If your ssh key has been created with a passphrase, please create an other one.

  1. On Windows only: open UEFI BIOS and make sure virtualization is turned 'on'
  2. On Windows only: open powershell as administrator and run: Add-MpPreference -ExclusionProcess winnfsd.exe
  3. On Windows only: open C:\Windows\System32\drivers\etc\hosts as administrator then add network_ip and magento_url
    Default values would be: 192.168.200.50 dev.magento.com
  4. On Linux only: in order to install NFS, run sudo apt install nfs-kernel-server
  5. On Linux/MacOS only: open /etc/hosts as sudo then add network_ip and magento_url
    Default values would be: 192.168.200.50 dev.magento.com

Installation

  1. Clone this project: git clone git@github.com:zepgram/magento2-fast-vm.git
  2. Copy/past: ssh.example rename it ssh then put your id_rsa and id_rsa.pub keys
  3. Copy/past: config.yaml.example rename it config.yaml
    Then customize configurations according to Yaml config overview
  4. If you want to import an existing database: create a compressed sql dump and name it db-dump.sql.gz.
    You must also fill crypt_key in config.yaml
  5. To start install run: vagrant up (duration: ~20 minutes)
  6. Finally run: vagrant ssh to access to your guest machine

Yaml config overview

  • Vmconf
    • machine_name: oracle virtual machine name (Vagrant Magento 2)
    • network_ip: virtual machine ip (192.168.200.50)
    • host_name: virtual machine host name (zepgram)
    • memory: RAM of virtual machine (4096)
    • cpus: CPU usage (2)
    • mount: nfs / rsync / default (nfs)
    • path:
      • 'app' mount only app directory /var/www/magento/app
      • 'root' mount whole directory /var/www/magento
    • provision: define shell provisionning sequence (all)
      • 'all' run all provisionner files
      • 'system' run only machine provisionner
      • 'magento' run magento provisionner
  • Composer
    • username: magento access set your magento credentials (magentoUsernameKey)
    • password: magento access set your magento credentials (magentoPasswordKey)
  • Git (optional)
    • name: git account username (John Doe)
    • email: git account email (john@doe.com)
    • host: set your git host server to add ssh key to "known hosts" (github.com)
    • repository: clone your existing magento project (ssh://git@github.com:project-name.git)
  • Magento
    • url: magento site host name (dev.magento.com)
      FI do not use .dev or .localhost as extension
    • source: define installation source (composer)
      • 'composer' install magento source code from official composer repository
      • 'git-branch-name' install magento project from your git repository based on defined branch (ex: master)
    • edition: magento project edition, used only on composer source installation (community)
      • 'community' install magento community edition
      • 'enterprise' install magento enterprise edition
    • version: set magento version and also define PHP version (2.3.3)
    • php_version: override the default required version by yours, for example '7.1' (default)
    • sample: install sample data, used only on composer source installation (true)
    • mode: magento mode (developer)
    • currency: set currency (USD)
    • language: set language (en_US)
    • time_zone: set time zone (Europe/London)
    • crypt_key: crypt key under your app/etc/env.php (only required if db-dump.sql.gz exist)

Path

  • root directory: mount the entire project.
  • app directory: mount only app directory. Ensure great performance by not sharing generated files between machines.

Mount options

RSYNC

Only useful on path set to root.

  • Loss of performance is due to files generated on the fly, by excluding them you can mount the whole directory root and get performance equal to an app mount.
  • The vagrant rsync-auto is launched by default on vagrant up, even with that if you need to force an update you can run vagrant rsync. Terminal should be kept open for rsync-auto: do not close it.
  • Rsync is unilateral, your host machine push files to guest but not the other way.
    Anyway if it's necessary, after a composer update for example, you can run vagrant rsync-back to push files from guest to host.
  • After first installation, you must run vagrant reload to enable file watching with rsync-auto.
    See Rsync option

NFS

Recommended for root and app path.
The most stable option, config has been made to ensure compliance with all OS. Less performant than rsync but files are perfectly shared between guest and host machine.

See NFS option

DEFAULT

It can be used with app path if you encountered any issue with NFS and rsync mount.

See basic usage

Extra provisions

You can add extra shell provisions.
Those provisions will be executed on pre-defined sequences:

  1. extra/001-env.sh his purpose is to provide extra environment variables or extra package, executed after script 001-system-env.sh
  2. extra/100-pre-build.sh define your specific system configuration before installation, executed after script 100-magento-pre.sh
  3. extra/120-post-build.sh you can execute magento command in this sequence, executed after script 120-magento-post.sh
  • To be executed you must remove the string -example from the filename script.
  • As an example of use, you can adapt data from your database import by using the script 100-pre-build.sh

Usage

Permission

Magento file system owner is configured for vagrant user, it means all commands in magento project must be executed by this user.
By default command line vagrant ssh will log you as vagrant user.

  • To re-apply magento permissions you can run permission directly in command line.

Command line

  • magento (Magento CLI for your project)
  • magento-cloud (CLI provided for Magento Cloud)
  • pestle (A collection of command line scripts for Magento 2 code generation)
  • magerun (The swiss army knife for Magento developers)
  • permission (Apply magento2 permissions on project)

Cron

Enable cron:

./bin/magento cron:install

Disable cron:

./bin/magento cron:remove

Mysql

Percona server 8.0 is installed for version >= 2.4.0

Elasticsearch

Version 7.6.x of Elasticsearch is available for Magento.
If your Magento version is lower than 2.4 then version 6.x will be installed.
For version lower than 2.4, you can disable it and fall back to mysql:

./bin/magento config:set catalog/search/engine mysql

Configuration

Package & Software

  • php + required extensions
  • curl
  • git
  • gitflow
  • vim
  • composer
  • nginx
  • php-fpm
  • percona
  • redis-server
  • elasticsearch
  • grunt
  • postfix
  • mailcatcher
  • pestle
  • magereun
  • adminer
  • magento-cloud cli
  • bin/magento bash completion

Credentials

  • User bash terminal
    • user: vagrant
  • Back-office
    • url: magento[url]/admin
    • user: magento.admin
    • pass: admin123
  • Database
    • user: vagrant
    • pass: vagrant
    • name: magento
  • Mailcatcher
    • url: [network_ip]:1080
  • Adminer
    • url: [network_ip]/adminer
  • Phpinfo
    • url: [network_ip]/php

Issues

Windows 10

There is a known issue with composer installation on windows 10.
This issue could not be solved yet, and has already been reported 2 times.

  • It's related to the computer and BIOS configuration.
  • It's only with "nfs" setting for mount option.

To solve this, just try to set mount option to "rsync", then after full installation you should be able to fallback to NFS.

Others

  • If you have trouble during installation please open a new issue on this git repository.

About

Optimal vagrant developer box for Magento2. Folders synced by nfs/rsync. This box includes Magento developer utilities.

License:MIT License


Languages

Language:Shell 89.1%Language:Ruby 10.9%