Works also with Apple Silicon. Development and Production environments with nginx server and certbot. Feel free to modify everything you think should be improved
Nginx (1.8) + Redis (6.2) + PHP-FPM (8.1) + MySQL (8.0.27) + XDebug (3.1.4) + Mailhog + RabbitMQ (3.9) + Elasticsearch (7.16.3)
Development|Production environments all in one
The docker stack is composed of the following containers
- redis
- rabbitmq
- elasticsearch
- mailhog
- php-fpm
- nginx
- mysql
- nginx-proxy
- phpmyadmin
Builds from the nginx folder.
Mounts the folder magento2 from the project main folder into the container volume /home/magento
.
Builds from the php-fpm folder.
Mounts the folder magento2 from the project main folder into the container volume /home/magento
.
Starts a redis container.
Opens up port: 6379
Please change or set the mysql environment variables
MYSQL_DATABASE: 'xxxx'
MYSQL_ROOT_PASSWORD: 'xxxx'
MYSQL_USER: 'xxxx'
MYSQL_PASSWORD: 'xxxx'
MYSQL_ALLOW_EMPTY_PASSWORD: 'xxxxx'
Default values:
MYSQL_DATABASE: 'magento_db'
MYSQL_ROOT_PASSWORD: 'root_pass'
MYSQL_USER: 'magento_user'
MYSQL_PASSWORD: 'PASSWD#'
MYSQL_ALLOW_EMPTY_PASSWORD: 'false'
Opens up port: 3306
Note: On your host, port 3306 might already be in use. So before running docker-compose.yml, under the docker-compose.yml's mysql section change the host's port number to something other than 3306, select any as long as that port is not already being used locally on your machine.
Starts a mailhog container.
Opens up port: 1025
and 8025
Starts a rabbitmq container.
Opens up port: 5672
and 15672
Starts a elasticsearch container.
Opens up port: 9200
and 9300
Edit your .env
file in root folder, change PROJECT_NAME
and PROJECT_VIRTUAL_HOST
:
PROJECT_NAME
- help you to create simple and clear container names.
PROJECT_VIRTUAL_HOST
- it is your main url address.
For example:
PROJECT_NAME=magento2
PROJECT_VIRTUAL_HOST=magento2.test
Edit your /etc/hosts
and add next line:
127.0.0.1 magento2.test mail.magento2.test elastic.magento2.test rabbit.magento2.test
To start/build the stack.
Use - docker-compose up
or docker-compose up -d
to run the container on detached mode.
Compose will take some time to execute.
After the build has finished you can press the ctrl+c and docker-compose stop all containers.
modify docker/production/auth.json
with your adobe key/password credential
You will check the latest version of Magento from link: https://magento.com/tech-resources/download
To the run installation process use next commands.
Create new project:
./scripts/composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.4 /home/magento
Install project:
./scripts/magento setup:install --base-url=http://magento2.test/ --db-host=mysql --db-name=magento_db --db-user=magento_user --db-password="PASSWD#" --admin-firstname=admin --admin-lastname=admin --admin-email=admin@admin.test --admin-user=admin --admin-password=admin1! --language=it_IT --currency=USD --timezone=Europe/Rome --use-rewrites=1 --elasticsearch-host=elasticsearch --elasticsearch-port=9200
bin/magento cache:clean
bin/magento index:reindex
bin/magento cache:clean
bin/magento setup:upgrade -d memory_limit=-1 bin/magento setup:static-content:deploy it_IT bin/magento index:reindex bin/magento cache:clean
bin/magento setup:upgrade -d memory_limit=-1 bin/magento setup:di:compile -d memory_limit=-1 bin/magento setup:static-content:deploy it_IT bin/magento index:reindex bin/magento cache:clean
To access the magento homepage, go to the following url: http://magento2.test
Also, you can open:
http://mail.magento2.test - Mailhog
http://elastic.magento2.test - Elasicsearch
http://rabbit.magento2.test - RabbitMQ (guest/guest for aceess)
Insert the right domain in init-letsencrypt-production.sh or init-letsencrypt-staging.sh and then run it