Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Magento Upgrade Support #115

Merged
merged 14 commits into from
Dec 20, 2016
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/.vagrant
/.idea
/log/debug.log
/log/*.log
/scripts/.current_nesting_level
.DS_Store
/scripts/.current_log_path
.DS_Store
13 changes: 8 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Added

- Added ability to configure number of CPUs for virtual machine via [etc/config.yaml](etc/config.yaml.dist)
- Added generation of basic sample data for testing purposes
- Ability to upgrade Magento using `m-switch-to-ce` and `m-switch-to-ee` (when `-u` flag is specified)
- Redis support for Magento caching
- Access to Magento developer mode and storefront/admin UI debugging features via [etc/config.yaml.dist](etc/config.yaml.dist)
- Access to Magento developer mode and storefront/admin UI debugging features via [etc/config.yaml](etc/config.yaml.dist)
- Composer-based installation support
- Magento cache warming up after re-install and clearing cache
- Magento cache warming up after re-install and clearing cache (when `-w` flag is specified)
- Tests configuration files are generated during project initialization
- Sample data support
- ElasticSearch support
Expand All @@ -40,7 +43,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Removed requirement for public github token due to Composer limitations (issue is fixed on Composer side)
- Changed requirement for minimum box version from 1.0 to 1.1
- Upgraded PHP 5.5.9 to PHP 5.6
- When [init_project.sh](init_project.sh) is executed, EE will be installed by default, if EE repository is specified in [etc/config.yaml.dist](etc/config.yaml.dist). Not supported on Windows hosts
- When [init_project.sh](init_project.sh) is executed, EE will be installed by default, if EE repository is specified in [etc/config.yaml](etc/config.yaml.dist). Not supported on Windows hosts

### Fixed

Expand All @@ -65,7 +68,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

- Moved provisioning scripts
- Magento project directory moved to vagrant project root. Current structure is as follows: `vagrant-magento/magento2ce/magento2ee`
- PHP 7.0 is installed by default instead of PHP 5.5.9 (can be configured in [etc/config.yaml.dist](etc/config.yaml.dist))
- PHP 7.0 is installed by default instead of PHP 5.5.9 (can be configured in [etc/config.yaml](etc/config.yaml.dist))
- Renamed configuration folder from `local.config` to `etc`
- Set minimum Vagrant version as 1.8
- Improved deployment speed in case of disabled NFS for folders sync
Expand All @@ -78,7 +81,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Added [project initialization script](init_project.sh) and host scripts for routine flows (compatible with OSX, *nix and Windows)
- Implemented static value of forwarded SSH port to prevent necessity to reconfigure software accessing guest via SSH
- Implemented collision prevention for IP address and host name (in case when several machines are created at once)
- Configuration file [etc/config.yaml.dist](etc/config.yaml.dist)
- Configuration file [etc/config.yaml](etc/config.yaml.dist)
- PHP 7.0 support
- PHP Storm configuration during project initialization (particularly automatic deployment settings)
- Automatic vagrant plugins installation
Expand Down
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* [Connecting to MySQL DB](#connecting-to-mysql-db)
* [View emails sent by Magento](#view-emails-sent-by-magento)
* [Accessing PHP and other config files](#accessing-php-and-other-config-files)
* [Upgrading Magento](#upgrading-magento)
* [Multiple Magento instances](#multiple-magento-instances)
* [Update Composer dependencies](#update-composer-dependencies)
* [Environment configuration](#environment-configuration)
Expand Down Expand Up @@ -139,18 +140,20 @@ Note, that semantic versioning is only used for `x.0` branches (not for `develop
## Day-to-day development scenarios

### Reinstall Magento
To save some time and get clear Magento installation, you can skip installation of software like web server or php.
The following command will clear Magento DB, Magento caches and reinstall Magento instance.

Go to 'vagrant-magento' created earlier and run in command line:
Use commands described in [Switch between CE and EE](#switch-between-ce-and-ee) section with `-f` flag. Before doing actual re-installation, these commands update linking of EE codebase, clear cache, update composer dependencies.

If no composer update and relinking of EE codebase is necessary, use the following command. It will clear Magento DB, Magento caches and reinstall Magento instance.

Go to the root of vagrant project in command line and execute:

```
bash m-reinstall
```

### Clear Magento cache

Go to 'vagrant-magento' created earlier and run in command line:
Go to the root of vagrant project in command line and execute:

```
bash m-clear-cache
Expand All @@ -170,6 +173,8 @@ bash m-switch-to-ee

Force switch can be done using `-f` flag even if already switched to the target edition. May be helpful to relink EE modules after switching between branches.

Upgrade can be performed instead of re-installation using `-u` flag.

:information_source: On Windows hosts (or when NFS mode is disabled in [config.yaml](etc/config.yaml.dist) explicitly) you will be asked to wait until code is uploaded to guest machine by PhpStorm (PhpStorm must be launched). To continue the process press any key.

### Sample data installation
Expand Down Expand Up @@ -226,6 +231,13 @@ Do not edit any symlinks using PhpStorm because it may break your installation.

After editing configs in IDE it is still required to restart related services manually.

### Upgrading Magento

Sometimes it is necessary to test upgrade flow. This can be easily done as follows (assuming that you have installed instance):

- For git-based installation - check out codebase corresponding to the target Magento version. Or modify your `composer.json` in case of composer-based installation
- Use commands described in [Switch between CE and EE](#switch-between-ce-and-ee) section with `-u` flag

### Multiple Magento instances

To install several Magento instances based on different code bases, just follow [Installation steps](#installation-steps) to initialize project in another directory on the host.
Expand Down
4 changes: 3 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module Config

config_data_dist = YAML.load_file(config_dist_file)
config_data = File.exists?(config_file) ? YAML.load_file(config_file) : {}
return config_data_dist.merge!(config_data)
return config_data_dist.deep_merge!(config_data)
end
end

Expand All @@ -30,6 +30,7 @@ magento_host_name = config_data['magento']['host_name']
magento_ip_address = config_data['guest']['ip_address']
forwarded_ssh_port = config_data['guest']['forwarded_ssh_port']
guest_memory = config_data['guest']['memory']
guest_cpus = config_data['guest']['cpus']

# NFS will be used for *nix and OSX hosts, if not disabled explicitly in config
use_nfs_for_synced_folders = !OS.is_windows && (config_data['guest']['use_nfs'] == 1)
Expand All @@ -44,6 +45,7 @@ Vagrant.configure(VAGRANT_API_VERSION) do |config|

config.vm.provider "virtualbox" do |vb|
vb.memory = guest_memory
vb.cpus = guest_cpus
# Uncomment option below to avoid issues with VirtualBox on Windows 10
# vb.gui=true
end
Expand Down
2 changes: 2 additions & 0 deletions etc/config.yaml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ guest:
use_nfs: 1
# [To apply changes: vagrant reload] Default is 2Gb, around 3Gb is necessary to run functional tests.
memory: 2048
# Recommended number of CPUs is 2
cpus: 1
ip_address: "192.168.10.2"
forwarded_ssh_port: 3000

Expand Down
4 changes: 3 additions & 1 deletion init_project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ vagrant_dir=$PWD

source "${vagrant_dir}/scripts/output_functions.sh"
resetNestingLevel
current_script_name=`basename "$0"`
initLogFile ${current_script_name}

debug_vagrant_project="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "debug_vagrant_project")"
if [[ ${debug_vagrant_project} -eq 1 ]]; then
Expand Down Expand Up @@ -240,4 +242,4 @@ if [[ ${host_os} == "Windows" ]] || [[ ${use_nfs} == 0 ]]; then
If not using PhpStorm, you can set up synchronization using rsync"
fi

info "See detailed log in '${vagrant_dir}/log/debug.log'. For even more details you can set debug:vagrant_project to 1 in config.yaml"
info "See detailed log in '${vagrant_dir}/log/${current_script_name}.log'. For even more details you can set debug:vagrant_project to 1 in config.yaml"
4 changes: 3 additions & 1 deletion m-bin-magento
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ cd "$(dirname "${BASH_SOURCE[0]}")" && vagrant_dir=$PWD

source "${vagrant_dir}/scripts/output_functions.sh"
resetNestingLevel
current_script_name=`basename "$0"`
initLogFile ${current_script_name}

debug_vagrant_project="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "debug_vagrant_project")"
if [[ ${debug_vagrant_project} -eq 1 ]]; then
Expand All @@ -18,4 +20,4 @@ vagrant ssh -c "\$MAGENTO_ROOT/bin/magento $arguments" 2> >(logError)
# To debug, comment out line above and uncomment line below
# vagrant ssh -c "php -d xdebug.remote_autostart=1 \$MAGENTO_ROOT/bin/magento $arguments" 2> >(logError)

info "See detailed log in '${vagrant_dir}/log/debug.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
info "See detailed log in '${vagrant_dir}/log/${current_script_name}.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
24 changes: 18 additions & 6 deletions m-clear-cache
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ cd "$(dirname "${BASH_SOURCE[0]}")" && vagrant_dir=$PWD

source "${vagrant_dir}/scripts/output_functions.sh"
resetNestingLevel
current_script_name=`basename "$0"`
initLogFile ${current_script_name}

warm_up_cache=0
while getopts 'w' flag; do
case "${flag}" in
w) warm_up_cache=1 ;;
*) error "Unexpected option" && exit 1;;
esac
done

debug_vagrant_project="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "debug_vagrant_project")"
if [[ ${debug_vagrant_project} -eq 1 ]]; then
Expand All @@ -14,10 +24,12 @@ fi

bash "${vagrant_dir}/scripts/host/m_clear_cache.sh" "$@" 2> >(logError)

incrementNestingLevel

bash "${vagrant_dir}/scripts/host/warm_up_cache.sh" 2> >(logError)

decrementNestingLevel
if [[ ${warm_up_cache} -eq 1 ]]; then
incrementNestingLevel
bash "${vagrant_dir}/scripts/host/warm_up_cache.sh" 2> >(logError)
decrementNestingLevel
else
info "Use 'bash ./m-clear-cache -w' to get automatic cache warm up"
fi

info "See detailed log in '${vagrant_dir}/log/debug.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
info "See detailed log in '${vagrant_dir}/log/${current_script_name}.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
4 changes: 3 additions & 1 deletion m-composer
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ cd "$(dirname "${BASH_SOURCE[0]}")" && vagrant_dir=$PWD

source "${vagrant_dir}/scripts/output_functions.sh"
resetNestingLevel
current_script_name=`basename "$0"`
initLogFile ${current_script_name}

debug_vagrant_project="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "debug_vagrant_project")"
if [[ ${debug_vagrant_project} -eq 1 ]]; then
Expand All @@ -14,4 +16,4 @@ fi

bash "${vagrant_dir}/scripts/host/m_composer.sh" "$@" 2> >(logError)

info "See detailed log in '${vagrant_dir}/log/debug.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
info "See detailed log in '${vagrant_dir}/log/${current_script_name}.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
4 changes: 3 additions & 1 deletion m-reinstall
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ cd "$(dirname "${BASH_SOURCE[0]}")" && vagrant_dir=$PWD

source "${vagrant_dir}/scripts/output_functions.sh"
resetNestingLevel
current_script_name=`basename "$0"`
initLogFile ${current_script_name}

debug_vagrant_project="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "debug_vagrant_project")"
if [[ ${debug_vagrant_project} -eq 1 ]]; then
Expand All @@ -14,4 +16,4 @@ fi

bash "${vagrant_dir}/scripts/host/m_reinstall.sh" "$@" 2> >(logError)

info "See detailed log in '${vagrant_dir}/log/debug.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
info "See detailed log in '${vagrant_dir}/log/${current_script_name}.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
4 changes: 3 additions & 1 deletion m-search-engine
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ cd "$(dirname "${BASH_SOURCE[0]}")" && vagrant_dir=$PWD

source "${vagrant_dir}/scripts/output_functions.sh"
resetNestingLevel
current_script_name=`basename "$0"`
initLogFile ${current_script_name}

debug_vagrant_project="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "debug_vagrant_project")"
if [[ ${debug_vagrant_project} -eq 1 ]]; then
Expand All @@ -15,4 +17,4 @@ fi
cd "${vagrant_dir}"
vagrant ssh -c "bash /vagrant/scripts/guest/m-search-engine ${@}" 2> >(logError)

info "See detailed log in '${vagrant_dir}/log/debug.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
info "See detailed log in '${vagrant_dir}/log/${current_script_name}.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
4 changes: 3 additions & 1 deletion m-switch-to-ce
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ cd "$(dirname "${BASH_SOURCE[0]}")" && vagrant_dir=$PWD

source "${vagrant_dir}/scripts/output_functions.sh"
resetNestingLevel
current_script_name=`basename "$0"`
initLogFile ${current_script_name}

debug_vagrant_project="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "debug_vagrant_project")"
if [[ ${debug_vagrant_project} -eq 1 ]]; then
Expand All @@ -14,4 +16,4 @@ fi

bash "${vagrant_dir}/scripts/host/m_switch_to_ce.sh" "$@" 2> >(logError)

info "See detailed log in '${vagrant_dir}/log/debug.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
info "See detailed log in '${vagrant_dir}/log/${current_script_name}.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
4 changes: 3 additions & 1 deletion m-switch-to-ee
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ cd "$(dirname "${BASH_SOURCE[0]}")" && vagrant_dir=$PWD

source "${vagrant_dir}/scripts/output_functions.sh"
resetNestingLevel
current_script_name=`basename "$0"`
initLogFile ${current_script_name}

debug_vagrant_project="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "debug_vagrant_project")"
if [[ ${debug_vagrant_project} -eq 1 ]]; then
Expand All @@ -14,4 +16,4 @@ fi

bash "${vagrant_dir}/scripts/host/m_switch_to_ee.sh" "$@" 2> >(logError)

info "See detailed log in '${vagrant_dir}/log/debug.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
info "See detailed log in '${vagrant_dir}/log/${current_script_name}.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
4 changes: 3 additions & 1 deletion m-varnish
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ cd "$(dirname "${BASH_SOURCE[0]}")" && vagrant_dir=$PWD

source "${vagrant_dir}/scripts/output_functions.sh"
resetNestingLevel
current_script_name=`basename "$0"`
initLogFile ${current_script_name}

debug_vagrant_project="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "debug_vagrant_project")"
if [[ ${debug_vagrant_project} -eq 1 ]]; then
Expand All @@ -15,4 +17,4 @@ fi
cd "${vagrant_dir}"
vagrant ssh -c "bash /vagrant/scripts/guest/m-varnish ${@}" 2> >(logError)

info "See detailed log in '${vagrant_dir}/log/debug.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
info "See detailed log in '${vagrant_dir}/log/${current_script_name}.log'. For even more details you can set 'debug:vagrant_project' to 1 in etc/config.yaml"
34 changes: 7 additions & 27 deletions scripts/colors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,35 @@
# CLI color functions
function red()
{
tput setaf 1
printf "\e[31m"
}

function bold()
{
tput bold
printf "\e[1m"
}

function green()
{
tput setaf 2
printf "\e[32m"
}

function yellow()
{
tput setaf 3
}

function yellow_background()
{
tput setab 3
printf "\e[33m"
}

function blue()
{
tput setaf 4
}

function magenta()
{
tput setaf 5
}

function cyan()
{
tput setaf 6
printf "\e[34m"
}

function grey()
{
tput setaf 7
}

function grey_background()
{
tput setab 7
printf "\e[37m"
}

function regular()
{
tput sgr0
printf "\e[m"
}
Loading