This repository provides a ready-to-use Magento 2 development environment using Warden.
- Warden installed and configured
- Docker and Docker Compose
- Git
# Clone this repository
git clone https://github.com/tuanhaviet22/docker-magento2.git
cd docker-magento2
# Start the environment
make up
# Install Magento
make install
# Install sample data (optional)
make install_sample_data
Run make help
to see all available commands with descriptions:
up
- Create and start docker containersstart
- Start environmentstop
- Stop the running environmentdeploy
- Deploy projectinstall
- Install Magentoinstall_sample_data
- Install sample datacomposer_install
- Install composer dependenciesdisable_2fa
- Disable Magento_TwoFactorAuth modulecron_install
- Configure and run cron jobs
flush
- Flush Magento cache
npm_install
- Run npm installbuild
- Build theme in production modewatch
- Watch your files for changes during the development
phpcs
- Run phpcsgitsniff
- Run phpcs for the changed files only
The environment includes several services:
Service | Description |
---|---|
PHP-FPM | PHP application server |
Nginx | Web server |
MariaDB | MySQL database |
Redis | Cache and session storage |
Varnish | HTTP cache |
RabbitMQ | Message broker |
OpenSearch | Search engine |
MailHog | Email testing |
URLs will follow the Warden convention, for example:
- Storefront: https://app.{project-name}.test/
- Admin: https://app.{project-name}.test/backend/
- RabbitMQ: https://rabbitmq.{project-name}.test/
- OpenSearch: https://opensearch.{project-name}.test/
This environment automatically configures:
- SSL certificates via Warden
- Redis for caching and sessions
- OpenSearch for catalog search
- RabbitMQ for message queue
# Access the PHP container shell
warden shell
# Run Magento CLI commands
warden env exec php-fpm bin/magento [command]
# View logs
warden env exec php-fpm tail -f var/log/system.log