Magento 2 OSX/Linux Docker
Update: Magento 2.4 compatible
./install.sh
only works for Magento 2.4 at the moment. Working on a generic solution to guarantee backward compatibility
Nginx with Pagespeed, MariaDB, PHP 7, Redis, Elasticsearch, Mailhog, Watchtower
- Good Docker Performance on MacOS by using http://docker-sync.io/
- With
install.sh
you can include your running project files with its DB Dump or Magento Sample Data, create fresh Magento 2 Install, create fresh Magento Install with Sample Data - Change settings under
.env
in root folder - Change PHP Versions 7.1, 7.2, 7.3, 7.4 with xdebug all based on php:alpine docker images
- PHP, Redis containers connect via sockets
- A preconfigured
env.php
connects to redis via sockets withinstall.sh
- Elastic Search container ist preconfigured with
install.sh
- Redis container ist preconfigured with
install.sh
- Mailhog Connection in Magento 2 DB ist preconfigured with
install.sh
be sure to use
allure-framework/allure-phpunit
1.2.3
instead of1.2.0
due to this issue
Requirements
MacOS: Install Docker and docker-sync
Linux: Install Docker and Docker-compose.
Use
docker.sh
to installdocker
anddocker-compose
on debian or Ubuntu based Systems
Get Source
git clone https://github.com/aliuosio/mage2.docker.git
Installation
Fresh Installation (latest magento 2 version) or your running project when located in your filesystem
cd mage2.docker
chmod +x *.sh
./install.sh
set absolute Path to a Shop Folder (Empty or Project) in installer use .env to change values after installation and activate on restart of containers
Backend
http://mage2.localhost/admin
User: mage2_admin
Password: mage2_admin123#T
Frontend
http://mage2.localhost
OSX: on first run very slow due to docker-sync update of local shop files volume in the background.
See .docker-sync/daemon.log
for progress
next startup after reboot of Host
./start.sh
to fix Redis Performance Issues (Linux Only)
sudo sysctl vm.overcommit_memory=1;
echo never /sys/kernel/mm/transparent_hugepage/enabled;
to fix ElasticSearch Performance Issues (Linux Only)
sudo sysctl vm.max_map_count=262144
Install sample data
chmod +x sample-data.sh
./sample-data.sh
PHP Container Usage
docker exec -it -u $USER mage2_php bash -l
Elasticsearch Usage
** Configured automatically with install.sh **
In Magento 2 Backend stores
-Configuration
-Catalog
-Catalog
-Tab: Catalog Search
Search Engine: Elasticsearch 7.0+
Elasticsearch Server Hostname: elasticsearch
You MUST set sysctl -w vm.max_map_count=262144
on the docker host system or the elasticsearch container goes down
On OSX see link: https://stackoverflow.com/questions/41192680/update-max-map-count-for-elasticsearch-docker-container-mac-host?rq=1
Mailhog Usage
Mail Client
http://mage2.localhost:8025
In Magento 2 Backend `stores` -`Configuration` -`Advanced` -`System`
-`Tab: SMTP Configuration and Settings (Gmail/Google/AWS/Office360 etc)`
Authentication method: NONE
SSL type: None
SMTP Host: mailhog
SMTP Port: 1025
Features
- Fresh Install or use magento 2 project on your file system using
./install.sh
- Nginx uses http2
- alternative OSX docker-compose file using docker-sync for better performance
- set Magento 2 Versions as configurable option of
ìnstall.sh
- using watchtower container to keep the containers current
- set project directory to where ever you want (as configurable option in .env)
- set PHP-FPM minor Versions under 7 (7.0, 7.1, 7.2, 7.3) as configurable option
- http basic authentication
- Nginx uses Pagespeed Module
- container to register SSL Cert by letsencrypt (only with valid domain)
- setup valid SSL certificates with Let's Encrypt container
- Mailhog container
- Magerun2 netz98 magerun CLI tools for Magento 2
- Extra Composer Packages
- hirak/prestissimo composer package
- Extra Composer Packages with Magento 2 Installer
- magepal/magento2-gmailsmtpapp SMTP Module
- vpietri/adm-quickdevbar Developer Toolbar
- mage2tv/magento-cache-clean Cache Cleaner
- both PHP GD and PHP Imagick are installed
- PHP Xdebug as configurable option (xdebug.idekey=docker)
- PHP Opcache enabled
- PHP redis enabled
- us your local User ssh keys from host in PHP container
- set Project Name and Namespace through
ìnstall.sh
prompt - create backup of
.env
afterinstall.sh
usage - only create
mage2_admin
user on fresh install ininstall.sh
install.sh
creates secure MariaDB passwords and saves them to.env
- added prompt for SSL to
ìnstall.sh
Todos
no magento 2 install on SQL File input- Exchange
docker-sync
withMutagen
- generic solution for
./install.sh
to guarantee backward compatibility - reduce the number of volumes
- set Time and Zone according to host
- Docker letsencrypt certification Container
- prompt to disable Two Factor Auth (for example in local enviroment)
exchange MySQL with MariaDB as soon as Magento 2 Installer fixes Mariadb container again- make Webserver(Apache or Nginx) configurable in
install.sh
anddocker-entrypoint.sh
- rename config_blueprints to config and move config files to .docker/config
- move
install.sh
methods to extra script run in php container native - move
sampledata.sh
methods to extra script run in php container native - simplify letsencrypt certificate embedding in nginx container
- optimize pagespeed caching
- Nginx Header Config passes at https://securityheaders.com/
Bugs
- fix SSL
Support
If you encounter any problems or bugs, please create an issue on GitHub.
Contribute
Please Contribute by creating a fork of this repository.
Follow the instructions here: https://help.github.com/articles/fork-a-repo/