a scalable Magento 2.0 image based on Alpine, PHP-FPM, NginX and MariaDB Galera Cluster
GPL-3.0 License
a scalable Magento 2.0 image based on Alpine, PHP-FPM, NginX and MariaDB Galera Cluster
docker run -ti -p 80:80 cusspvz/magento
docker run -ti cusspvz/magento
NOTE: I've used volume names instead of absolute paths, but please change accordingly with your needs.
WHAAAT????
Yes, this image is scalable. You just need to pass down how can it reach other nodes and it will scale MariaDB.
docker run -ti --name magento1 cusspvz/magento
docker run -ti --name magento2 -l magento1:magento1 -e NODES=magento1 cusspvz/magento
docker run -ti --name magento3 -l magento1:magento1 -e NODES=magento1 cusspvz/magento
NODES
Defaults to
(Empty string)
This variable will allow this container to scale among other nodes and share the same data (from database and other assets)
You just need to pass down a list delimited by a comma (node1,node2,node3...
)
and it will automatically configure and scale.
NOTE: This only needs one active host, it will actually discover the other ones automatically. In case you use [rancher] or other orchestration tool that provides a DNS for all the nodes, you could simply pass it instead.
WARNING: Clustering will be disabled in case you decide to use an external database, meaning you will be responsable for handling all the data, including the shared media resources such as product images.
MYSQL_HOST
Defaults to localhost
If this value is different than
localhost
, internal mysql server WON'T be initialized! Do this only in case you want to take care of data and scaling manually.
MYSQL_PORT
Defaults to 3306
MYSQL_DATABASE
Defaults to magento
MYSQL_USER
Defaults to root
MYSQL_PASSWORD
Defaults to ThisShouldBeChangableLater
nice password, hehehe
docker build -t magento .
docker run -ti -p 80:80 magento
inotifywait -mr --timefmt '%d/%m/%y %H:%M' --format '%T %w %f' \
-e close_write $(pwd) | \
while read date time dir file; do
docker build -t magento .
docker kill magento
docker rm magento
docker run -ti \
--name magento \
-v magento_settings:/magento/app/etc
-v magento_data:/magento/pub
-v magento_mysql_data:/var/lib/mysql
-p 80:80 \
magento &
done
There are a few images that covers Magento 2, fewer on MariaDB and even fewer on Alpine.
The main purpose of this image is to deliver a ready to use image, just launch it and you're ready to go!
Just launch your container with a different MYSQL_HOST
.
docker run -d --name=magento-mysql mysql;
docker run -d --name=magento \
-e MYSQL_HOST=mysql-server
-l magento-mysql:mysql-server \
cusspvz/magento;
Well, who doesn't want a Magento container to spend only about ~350MB of RAM? If you launch this stack separately you will face an ~1.8GB of RAM footprint.
Seems legit?
Then, while building it I've decided it should be completely scalable, so there it is.
Amn!
Just kidding, I'm not but if you really enjoyed this please spread the word. Show your love by sharing on Twitter and giving a star to this repo!
GPL 3.0
2016 - 'til Infinity Brought to you with <3 by Jos Moreira