Docker container for Magento development based on richarvey/nginx-php-fpm image.
- Alpine Linux 3.4.6
- PHP 7.1.12
- Nginx 1.13.7
- MariaDB 10.2
- Redis 3.2
- Git
- Docker
-
Clone the repository
$ git clone git@github.com:lsrocha/magento-docker.git $ cd magento-docker
-
Configure your services
This project provides you sample config files. After cloning it, copy them and make the necessary changes.
$ cp docker-compose.yml.sample docker-compose.yml $ cp config/nginx/default.conf.sample config/nginx/default.conf
-
Import your code
Import your Magento project into the resultant directory. Feel free to follow the best way for you, but be sure your project directory is called
magento
. For example, you can run:git clone [...] magento
,mv [...] magento
or evencomposer create-project [...] magento
(following Magento installation doc).Inside Magento root directory, don't forget to copy
nginx.conf.sample
file tonginx.conf
. -
Create docker containers
$ docker-compose up -d
Now your store is available at http://store.local
.
$ docker exec -it magento-docker_web_1 su dev -c bash
$ docker logs -f magento-docker_web_1
Point your client/IDE to port 9000 and enable script debugging on your browser. Extensions for this purpose can be found in Xdebug documentation.
-
Map your stores in
config/nginx/default.conf
map $http_host $MAGE_RUN_CODE { store.local default; storeview.local store1; } server { [...] server_name store.local storeview.local; [...] set $MAGE_RUN_TYPE store; # or website [...] }
-
Edit your
magento/.../nginx.conf
location ~ (index|get|static|report|404|503|health_check)\.php$ { [...] fastcgi_param MAGE_RUN_TYPE $MAGE_RUN_TYPE; fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE; include fastcgi_params; }