A dockerized magento 2 community environment ready for development or production.
It's inspired from dockerize-magento2
-
All containers run on Alpine Linux. As a result, the images are smaller, faster and all the containers work with the same rules.
-
Magento is totally independant from
Painless Magento 2
. Magento lives inside thesrc
directory. This is a volume in thephp
container, so you can usePainless Magento 2
to develop stores, websites or Magento extensions. After, you can use the same system for production or take your code from the source directory to use as you need. -
Composer runs out the containers. Composer is left outside on purpose to keep the containers small and facilitate their use. You always have access to the code in the volume
src
. You should use Composer in the host machine. You can apply your changes without stoping the containers. To run compose commands, go tosrc
directory.ex: install Fooman Goolge Analytics.
cd src composer require fooman/googleanalyticsplus-m2 cd .. bin/console mage setup:upgrade
-
It includes, alpine latest, php 7,2 , nginx run by socket, mariadb, redis, opcache and let's encrypt; xdebug is only install when the enviroment is set in
.env
file as developer.
For Linux users you must have a recent version of docker and docker-compose installed.
If you are a Mac or Windows user, use the Docker Toolbox.
You need to have php
and composer
installed on your host machine.
The instalation process is the same for development, staging or production. The difference is in the information you use to fill the .env
file.
To start, use .env.sample
to create this file.
cp .evn.sample .env
Open the file and fill each variable. Each variable has values by default, you can use them as it for development but please change all for your installation in production.
-
-
take a backup from your data base.
-
Add your existing Magento 2 code inide the
src
directory. -
In the root directory of this project run the installer.
bin/console install
-
When the instalation is done, connect with the phpadmin you just install and use your data base backup for apply your last version.
- If you prefer, you can connect by ssh with the mariadb container and apply your backup using mysqldump, you should add your backup in the directory
config/backups
it will appears inside container at the address/backups
- If you prefer, you can connect by ssh with the mariadb container and apply your backup using mysqldump, you should add your backup in the directory
-
Done, you can start to use or develop magento 2
-
-
-
In the root directory of this projet, run this line:
rm src/.gitkeep && composer create-project --repository=https://repo.magento.com/ magento/project-community-edition src && touch src/.gitkeep
The first time it will ask for your magento authentication keys, click here for obtain yours if you don't have ones.
-
In the root directory of this project run the installer.
bin/console install
-
Done, you can start to use or develop magento 2
-
Painless Magento 2
comes with bin/console
script that can be used to install Magento and to execute Magentos' bin/magento script inside the PHP docker container:
Trigger the Magento 2 installation process:
bin/console install
Start the docker containers:
bin/console start
Stop the docker containers:
bin/console stop
Execute bin/magento
inside the docker container:
bin/console mage [arguments]
For more information on how to use docker-compose visit: https://docs.docker.com/compose/
The install
action depends on some parameters such as usernames and passwords. We have put in some default values for you that will work for a quick test:
MAGE_DOMAIN=painlessmagento.test
# use the uid of the host owner of /src directory
U_ID=33
WEB_USER=www-data
# first 3 parts of ip network you like to use
NETWORK_BASE=169.254.81
# magento accepts this enviroments: default, developer or production
ENVIROMENT=developer
DATABASE_NAME=magedocker
DATABASE_USER=magento
DATABASE_PASSWORD=magedocker
DATABASE_ROOT_PASSWORD=magedocker_root
ORDER_PREFIX=inv
ADMIN_USERNAME=admin
ADMIN_FIRSTNAME=Jhon
ADMIN_LASTNAME=Doe
ADMIN_EMAIL=johndoe@example.com
ADMIN_PASSWORD=Magento
DEFAULT_LANGUAGE=en_US
DEFAULT_CURRENCY=USD
DEFAULT_TIMEZONE=America/New_York
BACKEND_FRONTNAME=management
PHPADMIN_PORT=8080
# patch for use volumes, outsite c:/Users,
# 1) add the project's directory to the shared directories in your VM.
# 2) write here the address you add inside the VM
ROOT_PROJECT=/absolute/path/to/your/projet
EMAIL_SENDER=sales@painlessmagento.test
SMTP_SERVER=smtp.mailtrap.io
SMTP_PORT=587
SMTP_USER=Your_User
SMTP_PASS=Your_Password
If you want to use different parameters change the values in the .env file to your needs.
After customizing the parameters just run trigger the installation with
bin/console install
Painless Magento 2 is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.
starting point and base of this project:
https://github.com/arvatoSCM/dockerize-magento2
use docker in windows home:
docker-compose file reference:
https://docs.docker.com/compose/compose-file/
Handling permissions with docker volumes:
https://denibertovic.com/posts/handling-permissions-with-docker-volumes/
docker nginx, let's encrypt configuration:
Add users in alpine linux:
Redis configuration:
https://devdocs.magento.com/guides/v2.3/config-guide/redis/redis-session.html
https://devdocs.magento.com/guides/v2.3/config-guide/redis/redis-pg-cache.html
magento cli instalation guide:
set cronjob in bash file: