It's expected that the Magento 2 project source code will be located and managed on the host to allow quick indexing of project files by IDE. All other infrastructure is deployed in kubernetes cluster on Minikube.
Current DevBox aims to support multi-service multi-instance deployment in one click. Multiple Magento projects should be installed in a single Kubernetes cluster and share resoruces. Each of the Magento projects may be deployed as a monolith or a set of services. The DevBox is optimized for development scenarios using local environment.
The environment also suitable for for Magento Commerce and Magento B2B development.
The project initialization script configures a complete development environment:
checkout_source_from
option in etc/instance/config.yaml)If you never used Kubernetes before, read the Kubernetes Docs first.
The software listed below should be available in PATH (except for PHP Storm).
devbox-magento/magento2ce
. Either method will produce a successful installation.Open terminal and change your directory to the one you want to contain Magento project.
Download or clone the project with DevBox configuration:
init_project.sh
has completed PhpStorm configuration in the initialize project step below.
git clone --recursive git@github.com:magento/magento2-kubernetes-devbox.git magento2-devbox
Optionally, if you use private repositories on GitHub or download packages from the Magento Marketplace using Composer.
etc/composer/auth.json
."github.com": "your-github-token"
to the github-oauth
section for GitHub authorization.repo.magento.com
section.etc/instance/<instance_name>.yaml
and make the necessary customizations. Instance name is Magento instance identifier that can only include letters and numbers.etc/env/config.yaml
and make the necessary customizations.Initialize the project (this will configure the environment, install Magento):
cd magento2-devbox
# NFS configuration is needed just once for each project, it will prompt for your password to make changes on the host
bash scripts/host/configure_nfs_exports.sh
bash init_project.sh
Use the magento2-devbox
directory as the project root in PHP Storm (not magento2-devbox/magento
). This is important, because in this case PHP Storm will be configured automatically by init_project.sh.
Configure the remote PHP interpreter in PHP Storm. Go to Preferences, then Languages and Frameworks. Click PHP and add a new remote interpreter. Select Deployment configuration as a source for connection details.
Some of default settings are available for override. These settings can be found in the etc/instance/config.yaml.dist and etc/env/config.yaml.dist.
To override settings create a copy of etc/env/config.yaml.dist under the name 'config.yaml' and add your custom settings.
You can create multiple copies of etc/instance/config.yaml.dist, each of those copies will be responsible for a separate Magento instance deployed in the DevBox. Config file name must only include alpha-numeric characters and will be used to isolate instances (for instance domain name generation, DB name etc).
Upon a successful installation, you'll see the location and URL of the newly-installed Magento 2 application in console.
Web access:
http://magento.<instance_name>
(can be found in etc/instance/<instance_name>.yaml
)http://magento.<instance_name>/admin/
admin/123123q
bash k-open-rabbitmq
, credentials admin
/123123q
etc/instance/<instance_name>.yaml
.
Codebase and DB access:
localhost
minikube ip
to get the IP and use port 30306
magento_<instance_name>
, magento_<instance_name>_integration_tests
root:123123q
Codebase on host
magento2-devbox/<instance_name>
etc/instance/<instance_name>.yaml
: magento2-devbox/<instance_name>/magento2ee
Current devbox project follows semantic versioning so feel free to pull the latest features and fixes, they will not break your project.
For example your current branch is 2.0
, then it will be safe to pull any changes from origin/2.0
. However branch 3.0
will contain changes backward incompatible with 2.0
.
Note, that semantic versioning is only used for x.0
branches (not for develop
or master
).
bash k-upgrade-environment
.
Use the following command to open current instance:
./m-open
Hostname can also be found in magento/host_name
section of etc/instance/<instance_name>.yaml.
Use commands described in 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 the project in command line and execute:
./m-reinstall
Go to the root of the project in command line and execute:
./m-clear-cache
Assume, that EE codebase is available in magento2-devbox/magento/magento2ee
.
The following commands will link/unlink EE codebase, clear cache, update composer dependencies and reinstall Magento.
Go to 'magento2-devbox' created earlier and run in command line:
./m-switch-to-ce
# OR
./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.
To install Magento with sample data using Git:
additional_repositories
in etc/instance/<instance_name>.yaml. To ensure the yaml file can be correctly parsed, only remove the #
and the space afterwards../m-switch-to-ce -f
or ./m-switch-to-ee -f
, depending on the edition to be installed. To disable sample data, comment out additional repositories and force-switch to necessary edition (using the same commands).If sample data is not showing, try the following:
magento2-devbox/<instance_name>
directory such as magento2-devbox/default
.git clone git@github.com:magento/magento2-sample-data.git
or git@github.com:magento/magento2-sample-data-ee.git
depending on the edition to be installed.magento2-devbox
directory../m-switch-to-ce -f
or ./m-switch-to-ee -f
, depending on the edition to be installed.To install Magento with sample data using Composer:
Follow the steps outlined here.
Several entities are generated for testing purposes by default using REST API after Magento installation:
customer@example.com
:123123qQ
)To disable this feature, set magento/generate_basic_data
in etc/instance/<instance_name>.yaml to 0
and run ./m-switch-to-ce -f
or ./m-switch-to-ee -f
, depending on the edition to be installed.
Go to 'magento2-devbox' created earlier and run in command line:
./m-bin-magento <command_name>
# e.g.
./m-bin-magento list
XDebug is already configured to connect to the host machine automatically. So just:
Go to 'magento2-devbox' created earlier and run in command line:
bash k-ssh-mysql
After successful login to the container run the following command and enter 123123q
when prompted for a password:
mysql -uroot -p
To connect remotely run minikube ip
to get the IP and use port 30306
Not available yet.
The following configuration files are used by default:
Sometimes it is necessary to test upgrade flow. This can be easily done as follows (assuming that you have installed instance):
composer.json
in case of composer-based installation-u
flagNot available yet.
Go to 'magento2-devbox' created earlier and run in command line:
./m-composer install
# OR
./m-composer update
See how to run Magento tests from PhpStorm using remote PHP in Kubernetes cluster
Not available yet.
Use the following commands to enable/disable varnish : m-varnish disable
or m-varnish enable
.
You can also set use_varnish: 1
in etc/env/config.yaml to use varnish. Changes will be applied on init_project.sh -f
.
The VCL content can be found in configmap.yaml.
Set search_engine: "elasticsearch"
in etc/env/config.yaml to use ElasticSearch as current search engine or search_engine: "mysql"
to use MySQL. Changes will be applied on m-reinstall
.
Use the following commands to switch between search engines without reinstalling Magento: m-search-engine elasticsearch
or m-search-engine mysql
.
Redis is configured as cache backend by default.
It is possible to reset project environment to default state, which you usually get just after project initialization. The following command will re-initialize Kubernetes cluster. Magento 2 code base (magento
directory) and etc/instance/<instance_name>.yaml and PhpStorm settings will stay untouched.
Go to 'magento2-devbox' created earlier and run in command line:
./init_project.sh -f
It is possible to reset Magento 2 code base at the same time. Magento 2 code base will be deleted and then cloned from the repositories specified in etc/config.yaml
./init_project.sh -fc
To reset PhpStorm project configuration, in addition to -f
specify -p
option:
./init_project.sh -fp
Ultimate project reset can be achieved by combining all available flags:
./init_project.sh -fcp
NodeJS not available yet.
The tests are executed on every PR on Travis CI. It is possible to configure the same tests to run on the forked repository.
In order to run composer-based Magento tests for the fork, repo.magento.com credentials must be set to COMPOSER_AUTH
environment variable on Travis CI, the variable value should be:
'{"http-basic": {"repo.magento.com": {"username": "<public_key>","password": "<secret_key>"}}}'
An extended testsuite by default is executed against the master branch only.
It is possible to execute an extended testsuite on every build by commenting out if: branch = master
in the .travis.yaml
The same tests can be run on local using the following command.
cd tests
bash ./<test-name>.sh
debug:devbox_project
option in etc/env/config.yaml to 1
magento2-devbox
directory as project root in PHP Storm (not magento2-devbox/magento
)magento2-devbox/.idea
. Run ./magento2-devbox/scripts/host/configure_php_storm.sh
. After opening project in PhpStorm again everything should look goodminikube stop && minikube delete && ./init_project.sh
.etc/docker/monolith/Dockerfile
./k-upgrade-environment
./k-status
to open kubernetes dashboard and delete Replica Set named magento2-monolith-*
. The container should be restarted and its Age should resetInput/output error command terminated with exit code 1
try to run the same command again, it will succeed after several trials../scripts/host/configure_etc_hosts.sh
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。