|
7 жил өмнө | |
---|---|---|
compose | 7 жил өмнө | |
images | 7 жил өмнө | |
lib | 7 жил өмнө | |
LICENSE.md | 8 жил өмнө | |
README.md | 7 жил өмнө |
Mark Shust's Magento Docker Configuration
View Dockerfiles:
This configuration is intended to be used as a Docker-based development environment for both Magento 1 and Magento 2.
Folders:
images
: Docker images for nginx and phpcompose
: sample setups with Docker ComposeNginx assumes you are running Magento 2, however you can easily run it with Magento 1 using the provided configuration file. Here is an example of this setup with Docker Compose.
The PHP images are fairly agnostic to which version of Magento you are running. The PHP 5 images do assume you are running Magento 1, and the PHP 7 images do assume you are running Magento 2, however the main difference is cronjob setup, and they can be easily modified for inverse usage.
This setup relies on docker-sync for syncing host files to the container volume, and vice versa.
gem install docker-sync
brew install coreutils
80|443|3306|9000|9001
are not in useYou will also need to Download & Install Docker Community Edition on the host machine. This configuration has been tested on Mac, but should also work on Mac, Windows and Linux.
Setup a new project using the Magento 2 compose skeleton:
mkdir magento-2.2.2 && cd $_
git init
git remote add origin git@github.com:markoshust/magento-docker.git
git fetch origin
git checkout origin/master -- compose/magento-2
mv compose/magento-2/* .
rm -rf compose .git
git init
Set a custom name for the external volume. Within docker-sync.yml
and docker-compose-dev.yml
there are three references to magento222_appdata
. Feel free to change these values to your project's name, for example myapp_appdata
. This will be important when you want to run multiple Docker Compose setups with multiple projects.
Download the Magento source code to the src
folder with: ./bin/download 2.2.2
Start your Docker containers with: ./bin/start
. It will take a few moments (or many moments) for docker-sync to initially sync all of your host files back to the containers. Magento 2 has many, many files, so please be patient.
Setup your ip loopback for proper IP resolution with Docker: ./bin/initloopback
Add an entry to /etc/hosts
with your custom domain: 10.254.254.254 magento-2.2.2.test
(assuming the domain you want to setup is magento-2.2.2.test
). Be sure to use a .test
tld, as .localhost
and .dev
will present issues with domain resolution.
Run Magento's setup install process with the command: ./bin/setup
. Feel free to edit this file to your liking; at the very least you will probably need to update the base-url
value to the domain you setup in step 6.
You may now access your site at http://magento-2.2.2.test
(or whatever domain you setup). Note that initial page loads will take a bit of time. Once items are primed, everything should load quite fast.
See the compose
folder for sample setups for both Magento 1 and Magento 2. Basically your source code should go in the src
folder, and you can then kick your project off with ./bin/start
. You may have to complete a few of the steps above to get things functioning properly.
./bin/bash
: Drop into the bash prompt of your Docker container. The phpfpm
container should be mainly used to access the filesystem within Docker../bin/cli
: Run any CLI command without going into the bash prompt. Ex. ./bin/cli ls
./bin/composer
: Run the composer binary. Ex. ./bin/composer install
./bin/download
: Download a version of Magento to the src
directory. Ex. ./bin/download 2.2.2
./bin/fixperms
: This will fix filesystem ownerships and permissions within Docker../bin/initloopback
: Setup your ip loopback for proper Docker ip resolution../bin/magento
: Run the Magento CLI. Ex: ./bin/magento cache:flush
./bin/setup
: Run the Magento setup process to install Magento from the source code../bin/start
: Start the Docker Compose process and your app. Ctrl+C to stop the process../bin/xdebug
: Disable or enable Xdebug. Ex. ./bin/xdebug enable
docker-compose.yml
file. So for example, MySQL's hostname is db
(not localhost
) when accessing it from a Docker container.Within Xdebug, create a new PHPStorm > Preferences > Languages & Frameworks > PHP > CLI Interpreter
and specify From Docker
. Choose Docker
, then select the markoshust/magento-php:7-0-fpm
image name, and the PHP Executable
to be php
. Hitting the reload executable button should find the correct PHP Version and Xdebug debugger configuration.
Open PHPStorm > Preferences > Languages & Frameworks > PHP > Debug
and set:
PHPSTORM
10.254.254.254
9001
Create a new server at PHPStorm > Preferences > Languages & Frameworks > PHP > Servers
. Set localhost
as the name and host, check Shared
, leave port 80
, and debugger Xdebug
. Check Use path mappings
and assigned the src
File/Directory to the absolute path on the server of /var/www/html
.
Create a new PHP Remote Debug
configuration at Run > Edit Configurations
. Name it localhost
. Check Filter debug connection by IDE Key
, select server localhost
, and set IDE key to PHPSTORM
.
Open up src/pub/index.php
, and set a breakpoint near the end of the file. Go to Run > Debug localhost
, and open up a web browser. Be sure to install a plugin like Xdebug helper which sets the IDE key to PHPStorm
automatically for you. Enable the browser extension and activate it on the site, and reload the site. Xdebug within PHPStorm should now enable the debugger and stop at the toggled breakpoint.
Please first setup Magento Marketplace authentication (details at http://devdocs.magento.com/guides/v2.0/install-gde/prereq/connect-auth.html).
Place your auth token at ~/.composer/auth.json
with the following contents, like so:
{
"http-basic": {
"repo.magento.com": {
"username": "MAGENTO_PUBLIC_KEY",
"password": "MAGENTO_PRIVATE_KEY"
}
}
}