Magento Development Environment Setup

*note, this documentation is unique to the Magento2-Cloud environment and is different from the Nurse.com webscale environment which is documented at the link Nurse.com Environment setup

This page is mostly deprecated. Please see https://relias.atlassian.net/wiki/spaces/CEMVP/pages/2402156575

Overview

We use Docker to run our VMs. We have created a small set of bin scripts that decorate docker commands for ease of use. We have also created custom base images and conventions for using Docker Compose to stand up projects locally. These projects have all dependencies like MySQL, Redis, ElasticSearch, and even multiple apps like Magento, Wordpress, etc. built right into them. 

Initial RoboDocker Setup

Docker needs to run on Linux. We have found that Docker for Windows and Mac have issues as of this writing.

We recommend Virtualbox to create your Linux VM.

Installing Linux as a host is also supported however you must follow the directions exactly and DO NOT create a local user account.

If you are already running Docker Desktop for Windows or Docker Desktop for Mac, uninstall it. Running Docker in a Linux VM is an overall better strategy.

VM Setup

Now, you will need to set up the RoboDocker VM using a clean Centos7 Minimal ISO.

Follow this guide for installing CentOS: VM Setup in Virtualbox

Networking

You also need to confirm that you can get out and that DNS resolves. Try this:

ping google.com

If you get timeouts or are unable to resolve the DNS, you need to investigate networking issues further.

If you are unable to reach google and chose bridged network connection, try changing your connection to NAT and see if this resolves the problem

You may need to to shut the vm down and try a different network adapter or possibly even a different network. Sometimes a simple reboot can fix it also.

Install RoboDocker

Once this VM is up and running, run this command as root to tie the VM to RoboDocker Puppet and install docker and other tools.

bash <(curl -s https://bitbucket.org/relias/puppet-vm-setup-script/raw/master/install_docker.sh)

The script will prompt you to set a Bitbucket app password. You should set Email, Read, and Write for the permissions and name it RoboDocker.

Relias Project Setup

Now, you are ready to start working the Relias Platform.

su webuser cd /var/www git clone git@bitbucket.org:relias/continuing-education-docker.git continuingeducation cd continuingeducation composer install bin/install

That's it! It will ask you a few questions and then do everything for you.

Working with the project

Once your project is set up, there are a few things you should know about how to work with it using our custom docker wrapping commands.

First, you need to be aware of the concept that there is a RoboDocker context and a project context. When we refer to RoboDocker, we mean running commands within the CentOS VM. When we say project, we mean running commands within one of the project's Docker containers, primarily the php-fpm container for PHP projects.

In your project's docker repo, you have a few commands available to you in your projects "bin" directory. This is really just a symlink to a shared repo Docker Bin Scripts.

These commands are convenience wrappers for common tasks with docker commands. This is to ease the learning curve. If you need to get more advanced, feel free to use docker commands directly.

Start by doing this in the Magento VM:

Now you are in the context of the PHP FPM container and can work with this like any other VM.

Code is located at /var/www/continuingeducation. Conductor is located at /home/webuser/conductor.

Conductor commands should work as expected.

Remember that you are in the PHP container context. If you want to run docker commands or bin/start, etc. you need to type "exit" to get back to the RoboDocker context.

Browsing the Website

Add the project to your hosts file on the same line as the robodocker entry

With the containers running, browse to your project in a browser with https://local.continuingeducation.com/. You should see the site.

MySQL

In any MySQL GUI like Magento Development Environment Setup, you will make a single connection to robodocker that all projects will share. This is a simple TCP/IP port 3306 connection to MySQL.

Host: robodocker
User: root
Password: catch-damage-seeing-slowly
Port: 3306

Filesystem

Windows

Robodocker provides a Samba share that is also shared across all projects. This is a one time setup.

Set up a network drive at \\robodocker. In windows, open an explorer window and browse to \\robodocker. Then, right click on www and click "Map Network Drive". Then do the same for the webuser home directory.

If windows security asks for username / password credentials use:

username: webuser
password: password1

Mac

Redis

You can use Redis Desktop Manager to connect to Redis and browse the databases. Configure it to point to robodocker and that's it really.

Important Bin Commands

Lifecycle

  • bin/install - This installs the project

  • bin/rebuild-docker - This rebuilds docker containers, used after a git pull typically

  • bin/rebuild-magento - This deletes your magento install and reinstalls  (loses all media and database etc)

Daily Use

  • bin/start - This starts up the docker containers for this project

  • bin/stop - this stops the containers

  • bin/bash - drops you inside bash shell inside container. You can pass a -u flag for user and a -c flag for container. Example: bin/bash -u root -c mysql

  • bin/logs - This can be used to tail logs using -f, you can also pipe to grep. 

Direct Commands

These run commands without dropping into the container context

  • bin/cli - This can be used to pass in commands, but it needs more documentation etc.

  • bin/conductor - this can be used to run conductor commands inside container bin/conductor help

  • bin/magento - this can be used to run magento CLI commands inside container

  • bin/n98-magerun - this can be used to run 

Built in Monitoring

RoboDocker has some useful built in monitoring tools.

Logins all default to admin/admin

Keeping RoboDocker Updated

After this initial setup, you can run this command at any time in the future to bring your RoboDocker VM up to date with the latest tools and configuration.