├── .gitignore ├── README.md ├── bin ├── compose │ ├── build │ ├── cleanup │ ├── down │ ├── restart │ └── up ├── composer ├── helpers │ ├── create-bind-mounted-folders │ ├── remove-frontend-folder │ └── remove-magento-folder ├── magento ├── magento-install ├── mysql ├── new-project │ ├── magento │ └── nuxt ├── node ├── run │ ├── adminer │ ├── elasticsearch │ ├── filebeat │ ├── kibana │ ├── logstash │ ├── mailhog │ ├── mysql │ ├── nginx │ ├── node │ ├── php-fpm │ ├── rabbitmq │ ├── redis │ └── redis-admin ├── variables └── xdebug │ ├── cli │ └── mode ├── docker-compose.yml └── images ├── adminer └── Dockerfile ├── elasticsearch ├── Dockerfile └── elasticsearch.yml ├── filebeat ├── Dockerfile └── filebeat.yml ├── kibana ├── Dockerfile └── kibana.yml ├── logstash ├── Dockerfile ├── logstash.yml └── pipeline │ └── logstash.conf ├── mailhog └── Dockerfile ├── mysql ├── Dockerfile ├── custom.my.cnf └── init │ ├── .gitignore │ └── custom.sql ├── nginx ├── Dockerfile └── default.conf ├── node └── Dockerfile ├── php-fpm ├── .composer │ └── .placeholder ├── Dockerfile ├── custom-php.ini └── php.ini ├── rabbitmq └── Dockerfile ├── redis-admin └── Dockerfile └── redis └── Dockerfile /.gitignore: -------------------------------------------------------------------------------- 1 | images/php-fpm/.composer/* 2 | nuxt/* 3 | magento/* 4 | .idea 5 | .DS_Store 6 | .cache -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker development environment for Magento 2 2 | 3 | Includes optional integration with Vue Storefront 2 4 | 5 | ```Rootless containers```, 6 | ```Docker```, 7 | ```Magento 2```, 8 | ```Nginx```, 9 | ```MySQL```, 10 | ```PHP-FPM```, 11 | ```Adminer```, 12 | ```Redis```, 13 | ```Redis Admin```, 14 | ```RabbitMQ```, 15 | ```Filebeat```, 16 | ```Elastic Search```, 17 | ```Logstash```, 18 | ```Kibana``` 19 | 20 | __Currently supported versions of Magento__ 21 | 22 | - 2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.4.4 23 | 24 | ## Setup 25 | 26 | ### Requirements and Prerequsites 27 | 28 | - Tested on MacOS (M1) and Linux, does not work on Windows 29 | - Have at least 16 GB RAM on your host system 30 | - (MacOS) Allocate at least 5 GB RAM to Docker Desktop 31 | - Install Docker and docker-compose 32 | - (Windows) Install Git bash and use it to run project shell commands located in bin folder 33 | - Add following to etc/hosts 34 | - 127.0.0.1 magento.local 35 | - 127.0.0.1 nuxt.magento.local 36 | - 127.0.0.1 kibana.magento.local 37 | - 127.0.0.1 redis.magento.local 38 | - 127.0.0.1 rabbitmq.magento.local 39 | - 127.0.0.1 adminer.magento.local 40 | 41 | ### Create new Magento project 42 | 43 | 1) Run ```bin/new-project/magento ``` 44 | - This will install new Magento project to "magento" folder 45 | - Magento 2 documentation https://devdocs.magento.com 46 | - Requires Magento version as an argument 47 | - Keys can be found in https://marketplace.magento.com/customer/accessKeys/ and you can opt-in to store your keys (login and password) to /home/dockeruser/.composer/auth.json, which is bind mounted to images/php-fpm/auth.json 48 | - Magento default settings - these can be edited in bin/new-project/magento 49 | - ```base-url=http://magento.local``` 50 | - ```db-host=mysql``` 51 | - ```db-name=magento``` 52 | - ```db-user=magento``` 53 | - ```db-password=magento``` 54 | - ```admin-firstname=admin``` 55 | - ```admin-lastname=admin``` 56 | - ```admin-email=admin@admin.com``` 57 | - ```admin-user=admin``` 58 | - ```admin-password=admin123``` 59 | - ```language=en_US``` 60 | - ```currency=USD``` 61 | - ```timezone=America/Chicago``` 62 | - ```use-rewrites=1``` 63 | - ```elasticsearch-host=elasticsearch``` 64 | - ```session-save=redis``` 65 | - ```session-save-redis-host=redis``` 66 | - ```session-save-redis-db=0 --session-save-redis-password=""``` 67 | - ```cache-backend=redis``` 68 | - ```cache-backend-redis-server=redis``` 69 | - ```cache-backend-redis-db=1``` 70 | - ```page-cache=redis``` 71 | - ```page-cache-redis-server=redis``` 72 | - ```page-cache-redis-db=2``` 73 | - ```amqp-host="rabbitmq"``` 74 | - ```amqp-port="5672"``` 75 | - ```amqp-user="guest"``` 76 | - ```amqp-password="guest"``` 77 | - ```amqp-virtualhost="/"``` 78 | 79 | ### Run an already existing Magento project 80 | 81 | 1) Add existing project 82 | - Paste your existing Magento project to magento folder 83 | 84 | 2) Run ```bin/compose/up``` 85 | 86 | ### Create new Vue Storefront 2 project with Magento 2 GraphQL integration 87 | 88 | 1) Run ```bin/new-project/vsf``` 89 | - Select Magento 2 integration 90 | - Running this command will install Vue Storefront 2 project to nuxt folder and start development server on http://nuxt.magento.local 91 | - You can start VSF 2 with ```bin/node yarn dev``` 92 | - VSF 2 documentation https://docs.vuestorefront.io/v2/ 93 | 94 | ### Configure Nginx and Magento logs to be viewed in Kibana 95 | 96 | 1) Go to http://kibana.magento.local/app/management/kibana/indexPatterns in your browser 97 | 2) If Magento installation was successful, then there should be "You have data in Elasticsearch. Now, create an index pattern." title on the page and "Create index pattern" button. Click on it. 98 | 99 | Create index pattern 100 | 101 | 3) On the next page, write "weblogs-*" into the text input and click on "Next step" button 102 | 103 | weblogs-* 104 | 105 | 4) Select @timestamp from dropdown and click on "Create index pattern" button 106 | 107 | @timestamp 108 | 109 | 5) All done. You should be able to analyse your logs on http://kibana.magento.local/app/discover (if not, then refresh magento.local in order to log something). 110 | 111 | Analyse logs 112 | 113 | Kibana should now be configured to display 5 types of logs: nginx error log (```nginx_error```), magento debug log (```magento_debug```), magento exception log (```magento_exception```), magento system log (```magento_system```) and magento reports (```magento_report```). Each log has its own tag (values in brackets), that can be used to filter search results in Kibana - click on "+ Add filter" on the left side and type in the name of the log you want to search in. 114 | 115 | Filter by tags 116 | 117 | ### Configure Xdebug 118 | 119 | 1) Run ```bin/xdebug/mode debug``` 120 | - You can turn off Xdebug by running ```bin/ide/xdebug off``` and turn it on again with ```bin/ide/xdebug debug```, you can also use this command to set all other Xdebug modes (https://xdebug.org/docs/all_settings#mode) 121 | 2) PhpStorm should offer you automatic setup after you add breakpoint and make http request (open magento.local in a browser) and correct settings should be similar to this: 122 | 123 | Preferences - PHP - Debug 124 | 125 | Preferences - PHP - Debug 126 | 127 | Preferences - PHP - Servers 128 | 129 | Preferences - PHP - Servers 130 | 131 | ### Xdebug CLI 132 | 133 | 1) Add breakpoints (via IDE) 134 | 135 | 2) RUN ```bin/xdebug/cli ``` 136 | - It is relative to magento folder, run ```bin/xdebug/cli pub/index.php``` to debug ```magento/pub/index.php``` 137 | - SERVER_NAME is optional 138 | 139 | ## Command Reference 140 | 141 | - ``` bin/compose/build ``` 142 | - Build all images for services defined in docker-compose.yml file 143 | - Accepts service name/s as argument/s in case you want to build one or more specific services 144 | - ``` bin/compose/cleanup ``` 145 | - Stop and remove all containers, images and volumes of the project 146 | - ``` bin/compose/restart ``` 147 | - Restart all services (containers) defined within docker-compose file 148 | - Accepts service name/s as argument/s in case you want to restart one or more specific services 149 | - ``` bin/compose/up ``` 150 | - Start all services (containers) defined within docker-compose file 151 | - Accepts service name/s as argument/s in case you want to start one or more specific services 152 | - ``` bin/compose/down ``` 153 | - Stop all services (containers) defined within docker-compose file 154 | - Accepts service name/s as argument/s in case you want to stop one or more specific services 155 | - ``` bin/compose/variables ``` 156 | - This command is only used by other commands and it provides required variables for them, such as user and group id 157 | - ``` bin/helpers/create-bind-mounted-folders``` 158 | - Stops containers, checks if bind mounted folders specified in docker-compose.yml file exist and creates them if they don't 159 | - ``` bin/helpers/remove-nuxt-folder ``` 160 | - Stops containers and removes nuxt folder 161 | - ``` bin/helpers/remove-magento-folder ``` 162 | - Stops containers and removes Magento folder 163 | - ``` bin/new-project/magento ``` 164 | - Creates new Magento project in Magento folder 165 | - ``` bin/new-project/vsf ``` 166 | - Creates new VSF 2 project in nuxt folder 167 | - ``` bin/composer ``` 168 | - Runs Composer command in magento folder within php-fpm container 169 | - ``` bin/magento ``` 170 | - Runs magento command in magento folder within php-fpm containe 171 | - ``` bin/mysql $@ ``` 172 | - Runs mysql command within mysql container 173 | - ``` bin/node $@ ``` 174 | - Runs supplied command within node container 175 | - ```bin/run/ $@``` 176 | - Runs supplied command within specified container (service) 177 | - ``` bin/xdebug/mode ``` 178 | - Sets xdebug.mode to php.ini within php-fpm container and restarts it 179 | - ``` bin/xdebug/cli ``` 180 | - Runs specified script (FILE_PATH) and then stops at defined breakpoint (via IDE) 181 | - It is relative to magento folder, run ```bin/xdebug/cli pub/index.php``` to debug ```magento/pub/index.php``` 182 | - SERVER_NAME is optional 183 | ## Troubleshooting 184 | 185 | - If elasticsearch container randomly stops working, then it is probably running out of RAM. Allocate more RAM to Docker Desktop and/or increase Xmx2g value specified in elasticsearch service configuration in docker-compose.yml and restart the container 186 | - You might encounter permission issues if you manually delete one of bind mounted folders, because docker will automatically recreate them with root permissions, which means, that your containers won't have write access to them, because all containers are running in rootless mode. 187 | - If filebeat container stops with the error below, then remove the container (or run bin/compose/cleanup to remove all containers and images) and run bin/helpers/fix-filebeat-permissions and then bin/compose/up 188 | - ```Exiting: error loading config file: config file ("filebeat.yml") can only be writable by the owner but the permissions are "-rw-rw-r--" (to fix the permissions use: 'chmod go-w /usr/share/filebeat/filebeat.yml')``` 189 | -------------------------------------------------------------------------------- /bin/compose/build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | cd ${DOCKER_DIRECTORY} 6 | 7 | # Build images 8 | docker-compose build "$@" 9 | 10 | cd ${APP_DIRECTORY} -------------------------------------------------------------------------------- /bin/compose/cleanup: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | # Stop running containers and remove images (-v parameter can be added to also remove volumes) 6 | ${DOCKER_BIN_DIRECTORY}/compose/down --rmi all "$@" 7 | 8 | cd ${DOCKER_DIRECTORY} 9 | 10 | # Remove stopped containers 11 | docker-compose rm 12 | 13 | cd ${APP_DIRECTORY} -------------------------------------------------------------------------------- /bin/compose/down: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | cd ${DOCKER_DIRECTORY} 6 | 7 | # Stop running containers 8 | docker-compose down "$@" 9 | 10 | cd ${APP_DIRECTORY} -------------------------------------------------------------------------------- /bin/compose/restart: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | cd ${DOCKER_DIRECTORY} 6 | 7 | # Build images if needed and create and start containers 8 | docker-compose restart "$@" 9 | 10 | cd ${APP_DIRECTORY} -------------------------------------------------------------------------------- /bin/compose/up: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | cd ${DOCKER_DIRECTORY} 6 | 7 | # Build images if needed and create and start containers 8 | docker-compose up -d "$@" 9 | 10 | cd ${APP_DIRECTORY} -------------------------------------------------------------------------------- /bin/composer: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | cd ${DOCKER_DIRECTORY} 6 | 7 | # Run Composer command 8 | docker-compose exec php-fpm sh -c "cd /home/dockeruser/magento && composer $@" 9 | 10 | cd ${APP_DIRECTORY} -------------------------------------------------------------------------------- /bin/helpers/create-bind-mounted-folders: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Stopping running containers" 4 | 5 | # If containers with bind mounted folders are running, then deleted folders will be immediately re-created by Docker with root permissions 6 | ${DOCKER_BIN_DIRECTORY}/compose/down 7 | 8 | if [ ! -d ${MAGENTO_DIRECTORY} ] 9 | then 10 | mkdir ${MAGENTO_DIRECTORY} 11 | echo "Created ${MAGENTO_DIRECTORY} folder" 12 | fi 13 | 14 | if [ ! -d "${MAGENTO_DIRECTORY}/var" ] 15 | then 16 | mkdir ${MAGENTO_DIRECTORY}/var 17 | echo "Created ${MAGENTO_DIRECTORY}/var folder" 18 | fi 19 | 20 | if [ ! -d "${MAGENTO_DIRECTORY}/var/log" ] 21 | then 22 | mkdir ${MAGENTO_DIRECTORY}/var/log 23 | echo "Created ${MAGENTO_DIRECTORY}/var/log folder" 24 | fi 25 | 26 | if [ ! -d "${MAGENTO_DIRECTORY}/var/report" ] 27 | then 28 | mkdir magento/var/report 29 | echo "Created ${MAGENTO_DIRECTORY}/var/report folder" 30 | fi 31 | 32 | if [ ! -d ${NUXT_DIRECTORY} ] 33 | then 34 | mkdir ${NUXT_DIRECTORY} 35 | echo "Created ${NUXT_DIRECTORY} folder" 36 | fi -------------------------------------------------------------------------------- /bin/helpers/remove-frontend-folder: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Stopping running containers" 4 | 5 | # If containers with bind mounted folders are running, then deleted folders will be immediatelly re-created by Docker with root permissions 6 | ${DOCKER_BIN_DIRECTORY}/compose/down 7 | 8 | rm -rf ${NUXT_DIRECTORY} 9 | -------------------------------------------------------------------------------- /bin/helpers/remove-magento-folder: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Remove Magento folder 4 | 5 | echo "Stopping running containers" 6 | 7 | # If containers with bind mounted folders are running, then deleted folders will be immediatelly re-created by Docker with root permissions 8 | ${DOCKER_BIN_DIRECTORY}/compose/down 9 | 10 | rm -rf ${MAGENTO_DIRECTORY} 11 | -------------------------------------------------------------------------------- /bin/magento: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | cd ${DOCKER_DIRECTORY} 6 | 7 | # Run Magento command 8 | docker-compose exec php-fpm /home/dockeruser/magento/bin/magento "$@" 9 | 10 | cd ${APP_DIRECTORY} 11 | -------------------------------------------------------------------------------- /bin/magento-install: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | cd ${DOCKER_DIRECTORY} 6 | 7 | # Ask user before removing content of the database 8 | while true; do 9 | read -p "Running this command will remove content of the database. Do you wish to proceed Y/n?" yn 10 | case $yn in 11 | [Yy]* ) break;; 12 | [Nn]* ) exit;; 13 | * ) echo "Please answer Y/n.";; 14 | esac 15 | done 16 | 17 | # Run pre install script, if exists 18 | if [ -f "$APP_DIRECTORY/scripts/magento-pre-install" ] 19 | then 20 | $APP_DIRECTORY/scripts/magento-pre-install 21 | fi 22 | 23 | # Install Magento 24 | docker-compose exec -T php-fpm /home/dockeruser/magento/bin/magento setup:install \ 25 | --base-url=http://magento.local \ 26 | --backend-frontname=admin \ 27 | --db-host=mysql \ 28 | --db-name=magento \ 29 | --db-user=magento \ 30 | --db-password=magento \ 31 | --admin-firstname=admin \ 32 | --admin-lastname=admin \ 33 | --admin-email=admin@admin.com \ 34 | --admin-user=admin \ 35 | --admin-password=admin123 \ 36 | --language=en_US \ 37 | --currency=USD \ 38 | --timezone=America/Chicago \ 39 | --use-rewrites=1 \ 40 | --elasticsearch-host=elasticsearch \ 41 | --elasticsearch-enable-auth=1 \ 42 | --elasticsearch-username="elastic" \ 43 | --elasticsearch-password="changeme" \ 44 | --session-save=redis \ 45 | --session-save-redis-host=redis \ 46 | --session-save-redis-db=0 --session-save-redis-password="" \ 47 | --cache-backend=redis \ 48 | --cache-backend-redis-server=redis \ 49 | --cache-backend-redis-db=1 \ 50 | --page-cache=redis \ 51 | --page-cache-redis-server=redis \ 52 | --page-cache-redis-db=2 \ 53 | --amqp-host="rabbitmq" \ 54 | --amqp-port="5672" \ 55 | --amqp-user="guest" \ 56 | --amqp-password="guest" \ 57 | --amqp-virtualhost="/" \ 58 | --cleanup-database 59 | 60 | # Run post install script, if exists 61 | if [ -f "$APP_DIRECTORY/scripts/magento-post-install" ] 62 | then 63 | $APP_DIRECTORY/scripts/magento-post-install 64 | fi 65 | 66 | cd ${APP_DIRECTORY} 67 | 68 | # Set developer mode 69 | ${DOCKER_BIN_DIRECTORY}/magento deploy:mode:set developer 70 | 71 | # Two factor authentication is enabled by default since version 2.4.0 72 | ${DOCKER_BIN_DIRECTORY}/magento module:disable Magento_TwoFactorAuth 73 | 74 | # Set session admin lifetime for one year 75 | ${DOCKER_BIN_DIRECTORY}/magento config:set admin/security/session_lifetime 31535999 76 | 77 | # Set SMTP host 78 | ${DOCKER_BIN_DIRECTORY}/magento config:set system/smtp/host mailhog 79 | 80 | # Set SMTP port 81 | ${DOCKER_BIN_DIRECTORY}/magento config:set system/smtp/port 1025 82 | echo "Mailhog has been configured." 83 | 84 | ${DOCKER_BIN_DIRECTORY}/magento config:set admin/security/use_form_key 0 85 | echo "Secret key in admin urls was disabled." 86 | 87 | ${DOCKER_BIN_DIRECTORY}/magento cache:flush 88 | -------------------------------------------------------------------------------- /bin/mysql: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | cd ${DOCKER_DIRECTORY} 6 | 7 | # Run Mysql command 8 | docker-compose exec mysql mysql -u magento -pmagento 9 | 10 | cd ${APP_DIRECTORY} -------------------------------------------------------------------------------- /bin/new-project/magento: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | if [ -z $1 ] 6 | then echo "Please select Magento 2 version. Currently supported versions: 2.4.x"; 7 | exit; 8 | fi 9 | 10 | # Ask user before removing magento folder and then re-creating it 11 | while true; do 12 | read -p "Running this command will remove content of magento folder. Do you wish to proceed Y/n?" yn 13 | case $yn in 14 | [Yy]* ) break;; 15 | [Nn]* ) exit;; 16 | * ) echo "Please answer Y/n.";; 17 | esac 18 | done 19 | 20 | # Remove Magento folder 21 | ${DOCKER_BIN_DIRECTORY}/helpers/remove-magento-folder 22 | 23 | # Create bind mounted folders 24 | ${DOCKER_BIN_DIRECTORY}/helpers/create-bind-mounted-folders 25 | 26 | # Start containers 27 | ${DOCKER_BIN_DIRECTORY}/compose/up 28 | 29 | cd ${DOCKER_DIRECTORY} 30 | 31 | # Create new project 32 | docker-compose exec php-fpm sh -c 'composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=$1 /home/dockeruser/temp && rm -rf /home/dockeruser/temp/var/log && rm -rf /home/dockeruser/temp/var/report && cp -r /home/dockeruser/temp/. /home/dockeruser/magento && rm -rf /home/dockeruser/temp' 33 | 34 | echo "New Magento project has been created." 35 | 36 | cd ${APP_DIRECTORY} 37 | 38 | # Ask user before removing content of the database 39 | while true; do 40 | read -p "Do you want to setup database Y/n?" yn 41 | case $yn in 42 | [Yy]* ) break;; 43 | [Nn]* ) exit;; 44 | * ) echo "Please answer Y/n.";; 45 | esac 46 | done 47 | 48 | ${DOCKER_BIN_DIRECTORY}/magento-install 49 | -------------------------------------------------------------------------------- /bin/new-project/nuxt: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | # Remove Nuxt folder 6 | ${DOCKER_BIN_DIRECTORY}/helpers/remove-nuxt-folder 7 | 8 | # Create bind mounted folders 9 | ${DOCKER_BIN_DIRECTORY}/helpers/create-bind-mounted-folders 10 | 11 | # Start containers 12 | ${DOCKER_BIN_DIRECTORY}/compose/up 13 | 14 | cd ${DOCKER_DIRECTORY} 15 | 16 | # Init project 17 | docker-compose exec node sh -c "cd /home/node && \ 18 | if [ -d temp ]; then rm -rf temp; fi && \ 19 | mkdir temp && \ 20 | cd temp && \ 21 | yarn create nuxt-app nuxt && \ 22 | mv /home/node/temp/nuxt/* /home/node/nuxt && \ 23 | rm -rf /home/node/temp" 24 | 25 | cd ${APP_DIRECTORY} -------------------------------------------------------------------------------- /bin/node: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | cd ${DOCKER_DIRECTORY} 6 | 7 | # Run Node command 8 | docker-compose exec node sh -c "cd /home/node/nuxt && $@" 9 | -------------------------------------------------------------------------------- /bin/run/adminer: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | cd ${DOCKER_DIRECTORY} 6 | 7 | # Run command in Adminer service (container) 8 | docker-compose exec adminer "$@" 9 | 10 | cd ${APP_DIRECTORY} 11 | -------------------------------------------------------------------------------- /bin/run/elasticsearch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | cd ${DOCKER_DIRECTORY} 6 | 7 | # Run command in Elasticsearch service (container) 8 | docker-compose exec elasticsearch "$@" 9 | 10 | cd ${APP_DIRECTORY} 11 | -------------------------------------------------------------------------------- /bin/run/filebeat: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | cd ${DOCKER_DIRECTORY} 6 | 7 | # Run command in Filebeat service (container) 8 | docker-compose exec filebeat "$@" 9 | 10 | cd ${APP_DIRECTORY} 11 | -------------------------------------------------------------------------------- /bin/run/kibana: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | cd ${DOCKER_DIRECTORY} 6 | 7 | # Run command in Kibana service (container) 8 | docker-compose exec kibana "$@" 9 | 10 | cd ${APP_DIRECTORY} 11 | -------------------------------------------------------------------------------- /bin/run/logstash: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | cd ${DOCKER_DIRECTORY} 6 | 7 | # Run command in Logstash service (container) 8 | docker-compose exec logstash "$@" 9 | 10 | cd ${APP_DIRECTORY} 11 | -------------------------------------------------------------------------------- /bin/run/mailhog: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | cd ${DOCKER_DIRECTORY} 6 | 7 | # Run command in Mailhog service (container) 8 | docker-compose exec mailhog "$@" 9 | 10 | cd ${APP_DIRECTORY} 11 | -------------------------------------------------------------------------------- /bin/run/mysql: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | cd ${DOCKER_DIRECTORY} 6 | 7 | # Run command in Mysql service (container) 8 | docker-compose exec mysql "$@" 9 | 10 | cd ${APP_DIRECTORY} 11 | -------------------------------------------------------------------------------- /bin/run/nginx: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | cd ${DOCKER_DIRECTORY} 6 | 7 | # Run command in Nginx service (container) 8 | docker-compose exec nginx "$@" 9 | 10 | cd ${APP_DIRECTORY} 11 | -------------------------------------------------------------------------------- /bin/run/node: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | cd ${DOCKER_DIRECTORY} 6 | 7 | # Run command in Node service (container) 8 | docker-compose exec node "$@" 9 | 10 | cd ${APP_DIRECTORY} 11 | -------------------------------------------------------------------------------- /bin/run/php-fpm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | cd ${DOCKER_DIRECTORY} 6 | 7 | # Run command in PHP-FPM service (container) 8 | docker-compose exec php-fpm "$@" 9 | 10 | cd ${APP_DIRECTORY} 11 | -------------------------------------------------------------------------------- /bin/run/rabbitmq: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | cd ${DOCKER_DIRECTORY} 6 | 7 | # Run command in Rabbitmq service (container) 8 | docker-compose exec rabbitmq "$@" 9 | 10 | cd ${APP_DIRECTORY} 11 | -------------------------------------------------------------------------------- /bin/run/redis: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | cd ${DOCKER_DIRECTORY} 6 | 7 | # Run command in Redis service (container) 8 | docker-compose exec redis "$@" 9 | 10 | cd ${APP_DIRECTORY} 11 | -------------------------------------------------------------------------------- /bin/run/redis-admin: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | cd ${DOCKER_DIRECTORY} 6 | 7 | # Run command in Redis Admin service (container) 8 | docker-compose exec redis-admin "$@" 9 | 10 | cd ${APP_DIRECTORY} 11 | -------------------------------------------------------------------------------- /bin/variables: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export USER_ID=$(id -u) 4 | export GROUP_ID=$(id -u) 5 | 6 | export APP_DIRECTORY=$(pwd) 7 | 8 | export DOCKER_BIN_DIRECTORY=${APP_DIRECTORY}/bin 9 | export DOCKER_DIRECTORY=${APP_DIRECTORY} 10 | export DOCKER_IMAGE_FOLDER="images" # used in Dockerfiles as relative path to the context (APP_DIRECTORY) 11 | 12 | export MAGENTO_DIRECTORY=${APP_DIRECTORY}/magento 13 | 14 | export NUXT_DIRECTORY=${APP_DIRECTORY}/nuxt 15 | 16 | export CLI_XDEBUG_SERVER_NAME=magento.local 17 | -------------------------------------------------------------------------------- /bin/xdebug/cli: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | cd ${DOCKER_DIRECTORY} 6 | 7 | if [ -z $1 ] 8 | then echo "First argument has to be relative path () to target file"; 9 | exit; 10 | fi 11 | 12 | docker-compose exec -e XDEBUG_SESSION=1 -e PHP_IDE_CONFIG="serverName=$CLI_XDEBUG_SERVER_NAME" php-fpm "$@" 13 | 14 | cd ${APP_DIRECTORY} 15 | -------------------------------------------------------------------------------- /bin/xdebug/mode: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . bin/variables 4 | 5 | # Find and replace everything after "xdebug.mode=" until end of the line with the argument and restart php-fpm container 6 | 7 | # Documentation https://xdebug.org/docs/all_settings#mode 8 | 9 | # off 10 | # - Nothing is enabled. Xdebug does no work besides checking whether functionality is enabled. Use this setting if you want close to 0 overhead. 11 | 12 | # develop 13 | # - Enables Development Aids including the overloaded var_dump(). 14 | 15 | # coverage 16 | # - Enables Code Coverage Analysis to generate code coverage reports, mainly in combination with PHPUnit. 17 | 18 | # debug 19 | # - Enables Step Debugging. This can be used to step through your code while it is running, and analyse values of variables. 20 | 21 | # gcstats 22 | # - Enables Garbage Collection Statistics to collect statistics about PHP's Garbage Collection Mechanism. 23 | 24 | # profile 25 | # - Enables Profiling, with which you can analyse performance bottlenecks with tools like KCacheGrind. 26 | 27 | # trace 28 | # - Enables the Function Trace feature, which allows you record every function call, including arguments, variable assignment, and return value that is made during a request to a file. 29 | 30 | cd ${DOCKER_DIRECTORY} 31 | 32 | if [ $(uname) = "Darwin" ] 33 | then 34 | docker-compose exec php-fpm sed -i '' "s/xdebug.mode=.*/xdebug.mode=$1/g" /usr/local/etc/php/php.ini 35 | else 36 | docker-compose exec php-fpm sed -i "s/xdebug.mode=.*/xdebug.mode=$1/g" /usr/local/etc/php/php.ini 37 | fi 38 | 39 | echo "reloading php-fpm configuration" 40 | docker-compose exec php-fpm kill -USR2 1 41 | 42 | cd ${APP_DIRECTORY} 43 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | 3 | services: 4 | php-fpm: 5 | build: 6 | args: 7 | DOCKER_IMAGE_FOLDER: $DOCKER_IMAGE_FOLDER 8 | GROUP_ID: $GROUP_ID 9 | USER_ID: $USER_ID 10 | context: $APP_DIRECTORY 11 | dockerfile: $DOCKER_DIRECTORY/images/php-fpm/Dockerfile 12 | command: sh -c "cd /home/dockeruser && chown $USER_ID:$GROUP_ID magento && php-fpm" 13 | container_name: docker-magento_php-fpm 14 | depends_on: 15 | - mysql 16 | networks: 17 | - external 18 | - internal 19 | extra_hosts: 20 | - "host.docker.internal:host-gateway" 21 | volumes: 22 | - $MAGENTO_DIRECTORY:/home/dockeruser/magento 23 | - $DOCKER_DIRECTORY/images/php-fpm/custom-php.ini:/usr/local/etc/php/conf.d/custom-php.ini 24 | - $DOCKER_DIRECTORY/images/php-fpm/.composer:/home/dockeruser/.composer 25 | 26 | node: 27 | build: 28 | args: 29 | GROUP_ID: $GROUP_ID 30 | USER_ID: $USER_ID 31 | context: $APP_DIRECTORY 32 | dockerfile: $DOCKER_DIRECTORY/images/node/Dockerfile 33 | command: sh -c "cd /home/node && chown $USER_ID:$GROUP_ID nuxt && tail -f /dev/null" 34 | container_name: docker-magento_node 35 | environment: 36 | MAGENTO_GRAPHQL: "http://nginx:8080/graphql" 37 | networks: 38 | - external 39 | - internal 40 | volumes: 41 | - $NUXT_DIRECTORY:/home/node/nuxt 42 | 43 | nginx: 44 | build: 45 | args: 46 | GROUP_ID: $GROUP_ID 47 | USER_ID: $USER_ID 48 | context: $APP_DIRECTORY 49 | dockerfile: $DOCKER_DIRECTORY/images/nginx/Dockerfile 50 | command: sh -c "cd /home/dockeruser && chown $USER_ID:$GROUP_ID magento && nginx -g 'daemon off;'" 51 | container_name: docker-magento_nginx 52 | depends_on: 53 | - php-fpm 54 | - node 55 | - adminer 56 | - kibana 57 | - rabbitmq 58 | - redis-admin 59 | - mailhog 60 | networks: 61 | - external 62 | ports: 63 | - 80:8080 64 | volumes: 65 | - $MAGENTO_DIRECTORY:/home/dockeruser/magento 66 | - $DOCKER_DIRECTORY/images/nginx/default.conf:/etc/nginx/conf.d/default.conf 67 | - nginx_logs:/var/log/nginx 68 | 69 | mysql: 70 | build: 71 | context: $APP_DIRECTORY 72 | dockerfile: $DOCKER_DIRECTORY/images/mysql/Dockerfile 73 | container_name: docker-magento_mysql 74 | environment: 75 | MYSQL_DATABASE: "magento" 76 | MYSQL_PASSWORD: "magento" 77 | MYSQL_ROOT_PASSWORD: "magento" 78 | MYSQL_USER: "magento" 79 | networks: 80 | - internal 81 | platform: linux/amd64 82 | volumes: 83 | - $APP_DIRECTORY/images/mysql/init:/docker-entrypoint-initdb.d 84 | - mysql:/var/lib/mysql 85 | - $DOCKER_DIRECTORY/images/mysql/custom.my.cnf:/etc/mysql/conf.d/custom.my.cnf 86 | 87 | adminer: 88 | build: 89 | context: $APP_DIRECTORY 90 | dockerfile: $DOCKER_DIRECTORY/images/adminer/Dockerfile 91 | container_name: docker-magento_adminer 92 | depends_on: 93 | - mysql 94 | networks: 95 | - external 96 | - internal 97 | 98 | elasticsearch: 99 | build: 100 | args: 101 | DOCKER_IMAGE_FOLDER: $DOCKER_IMAGE_FOLDER 102 | GROUP_ID: $GROUP_ID 103 | USER_ID: $USER_ID 104 | context: $APP_DIRECTORY 105 | dockerfile: $DOCKER_DIRECTORY/images/elasticsearch/Dockerfile 106 | container_name: docker-magento_elasticsearch 107 | environment: 108 | ELASTIC_PASSWORD: changeme 109 | ES_JAVA_OPTS: "-Xms1g -Xmx2g" 110 | networks: 111 | - internal 112 | volumes: 113 | - elasticsearch:/usr/share/elasticsearch/data 114 | - $DOCKER_DIRECTORY/images/elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml 115 | 116 | logstash: 117 | build: 118 | args: 119 | DOCKER_IMAGE_FOLDER: $DOCKER_IMAGE_FOLDER 120 | context: $APP_DIRECTORY 121 | dockerfile: $DOCKER_DIRECTORY/images/logstash/Dockerfile 122 | container_name: docker-magento_logstash 123 | depends_on: 124 | - elasticsearch 125 | environment: 126 | LS_JAVA_OPTS: "-Xmx1g -Xms1g" 127 | networks: 128 | - internal 129 | volumes: 130 | - $DOCKER_DIRECTORY/images/logstash/logstash.yml:/usr/share/logstash/config/logstash.yml 131 | - $DOCKER_DIRECTORY/images/logstash/pipeline:/usr/share/logstash/pipeline 132 | 133 | filebeat: 134 | build: 135 | args: 136 | DOCKER_IMAGE_FOLDER: $DOCKER_IMAGE_FOLDER 137 | context: $APP_DIRECTORY 138 | dockerfile: $DOCKER_DIRECTORY/images/filebeat/Dockerfile 139 | container_name: docker-magento_filebeat 140 | depends_on: 141 | - logstash 142 | networks: 143 | - internal 144 | volumes: 145 | - $DOCKER_DIRECTORY/images/filebeat/filebeat.yml:/usr/share/filebeat/filebeat.yml 146 | - nginx_logs:/var/log/nginx 147 | - $MAGENTO_DIRECTORY/var/log:/var/log/magento 148 | - $MAGENTO_DIRECTORY/var/report:/var/report/magento 149 | 150 | kibana: 151 | build: 152 | args: 153 | DOCKER_IMAGE_FOLDER: $DOCKER_IMAGE_FOLDER 154 | context: $APP_DIRECTORY 155 | dockerfile: $DOCKER_DIRECTORY/images/kibana/Dockerfile 156 | container_name: docker-magento_kibana 157 | depends_on: 158 | - elasticsearch 159 | networks: 160 | - external 161 | - internal 162 | platform: linux/amd64 163 | volumes: 164 | - $DOCKER_DIRECTORY/images/kibana/kibana.yml:/usr/share/kibana/config/kibana.yml 165 | 166 | rabbitmq: 167 | build: 168 | context: $APP_DIRECTORY 169 | dockerfile: $DOCKER_DIRECTORY/images/rabbitmq/Dockerfile 170 | container_name: docker-magento_rabbitmq 171 | networks: 172 | - external 173 | - internal 174 | 175 | redis: 176 | build: 177 | context: $APP_DIRECTORY 178 | dockerfile: $DOCKER_DIRECTORY/images/redis/Dockerfile 179 | container_name: docker-magento_redis 180 | networks: 181 | - internal 182 | 183 | redis-admin: 184 | build: 185 | context: $APP_DIRECTORY 186 | dockerfile: $DOCKER_DIRECTORY/images/redis-admin/Dockerfile 187 | container_name: docker-magento_redis-admin 188 | depends_on: 189 | - redis 190 | environment: 191 | REDIS_1_HOST: "redis" 192 | networks: 193 | - external 194 | - internal 195 | 196 | mailhog: 197 | build: 198 | context: $APP_DIRECTORY 199 | dockerfile: $DOCKER_DIRECTORY/images/mailhog/Dockerfile 200 | container_name: docker-magento_mailhog 201 | networks: 202 | - internal 203 | - external 204 | 205 | networks: 206 | internal: 207 | external: 208 | 209 | volumes: 210 | elasticsearch: 211 | mysql: 212 | nginx_logs: 213 | -------------------------------------------------------------------------------- /images/adminer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM adminer:4.8.1-fastcgi -------------------------------------------------------------------------------- /images/elasticsearch/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM elasticsearch:7.12.1 2 | 3 | ARG DOCKER_IMAGE_FOLDER 4 | 5 | # ARG GROUP_ID 6 | # ARG USER_ID 7 | # 8 | # RUN groupmod -g $GROUP_ID elasticsearch 9 | # RUN usermod -u $USER_ID -g $GROUP_ID elasticsearch 10 | # RUN chown -R elasticsearch /usr/share/elasticsearch 11 | # RUN sed -i -e "s/--userspec=1000/--userspec=$USER_ID/g" \ 12 | # -e "s/UID 1000/UID $USER_ID/" \ 13 | # -e "s/chown -R 1000/chown -R $USER_ID/" /usr/local/bin/compose-entrypoint.sh 14 | # RUN chown elasticsearch /usr/local/bin/compose-entrypoint.sh 15 | 16 | COPY --chown=elasticsearch:elasticsearch $DOCKER_IMAGE_FOLDER/elasticsearch/elasticsearch.yml /usr/share/elasticsearch/config/elasticsearch.yml 17 | 18 | USER elasticsearch -------------------------------------------------------------------------------- /images/elasticsearch/elasticsearch.yml: -------------------------------------------------------------------------------- 1 | cluster.name: "docker-cluster" 2 | network.host: 0.0.0.0 3 | discovery.type: single-node 4 | xpack.license.self_generated.type: trial 5 | xpack.security.enabled: true 6 | xpack.monitoring.collection.enabled: true -------------------------------------------------------------------------------- /images/filebeat/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM elastic/filebeat:7.13.3 2 | 3 | ARG DOCKER_IMAGE_FOLDER 4 | 5 | USER root 6 | 7 | COPY --chown=filebeat:filebeat $DOCKER_IMAGE_FOLDER/filebeat/filebeat.yml /usr/share/filebeat/filebeat.yml -------------------------------------------------------------------------------- /images/filebeat/filebeat.yml: -------------------------------------------------------------------------------- 1 | filebeat.inputs: 2 | - type: log 3 | enabled: true 4 | paths: 5 | - /var/log/nginx/error.log 6 | tags: ["nginx_error"] 7 | - type: log 8 | enabled: true 9 | paths: 10 | - /var/log/magento/debug.log 11 | tags: ["magento_debug"] 12 | - type: log 13 | enabled: true 14 | paths: 15 | - /var/log/magento/exception.log 16 | tags: ["magento_exception"] 17 | - type: log 18 | enabled: true 19 | paths: 20 | - /var/log/magento/system.log 21 | tags: ["magento_system"] 22 | - type: log 23 | enabled: true 24 | paths: 25 | - /var/report/magento/* 26 | tags: ["magento_report"] 27 | 28 | output.logstash: 29 | enabled: true 30 | hosts: ["logstash:5044"] 31 | 32 | # output.elasticsearch: 33 | # hosts: ["http://elasticsearch:9200"] 34 | # username: "elastic" 35 | # password: "changeme" 36 | setup.kibana: 37 | host: "http://kibana:5601" 38 | username: "elastic" 39 | password: "changeme" -------------------------------------------------------------------------------- /images/kibana/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM kibana:7.12.1 2 | 3 | ARG DOCKER_IMAGE_FOLDER 4 | 5 | USER root 6 | 7 | COPY --chown=kibana:kibana $DOCKER_IMAGE_FOLDER/kibana/kibana.yml /usr/share/kibana/config/kibana.yml 8 | 9 | USER kibana -------------------------------------------------------------------------------- /images/kibana/kibana.yml: -------------------------------------------------------------------------------- 1 | server.name: kibana 2 | server.host: "0" 3 | elasticsearch.hosts: [ "http://elasticsearch:9200" ] 4 | xpack.monitoring.ui.container.elasticsearch.enabled: true 5 | elasticsearch.username: "elastic" 6 | elasticsearch.password: "changeme" -------------------------------------------------------------------------------- /images/logstash/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM logstash:7.13.2 2 | 3 | ARG DOCKER_IMAGE_FOLDER 4 | 5 | USER root 6 | 7 | COPY --chown=logstash:logstash $DOCKER_IMAGE_FOLDER/logstash/pipeline/logstash.conf /usr/share/logstash/pipeline/logstash.conf 8 | 9 | COPY --chown=logstash:logstash $DOCKER_IMAGE_FOLDER/logstash/logstash.yml /usr/share/logstash/config/logstash.yml 10 | 11 | USER logstash -------------------------------------------------------------------------------- /images/logstash/logstash.yml: -------------------------------------------------------------------------------- 1 | http.host: "0.0.0.0" 2 | xpack.monitoring.elasticsearch.hosts: [ "http://elasticsearch:9200" ] 3 | xpack.monitoring.enabled: true 4 | xpack.monitoring.elasticsearch.username: "elastic" 5 | xpack.monitoring.elasticsearch.password: "changeme" -------------------------------------------------------------------------------- /images/logstash/pipeline/logstash.conf: -------------------------------------------------------------------------------- 1 | input { 2 | beats { 3 | port => 5044 4 | host => "0.0.0.0" 5 | } 6 | } 7 | 8 | filter { 9 | grok { 10 | match => [ "message" , "%{COMBINEDAPACHELOG}+%{GREEDYDATA:extra_fields}"] 11 | overwrite => [ "message" ] 12 | } 13 | mutate { 14 | convert => ["response", "integer"] 15 | convert => ["bytes", "integer"] 16 | convert => ["responsetime", "float"] 17 | } 18 | geoip { 19 | source => "clientip" 20 | target => "geoip" 21 | add_tag => [ "nginx-geoip" ] 22 | } 23 | date { 24 | match => [ "timestamp" , "dd/MMM/YYYY:HH:mm:ss Z" ] 25 | remove_field => [ "timestamp" ] 26 | } 27 | } 28 | 29 | output { 30 | elasticsearch { 31 | hosts => ["http://elasticsearch:9200"] 32 | index => "weblogs-%{+YYYY.MM.dd}" 33 | document_type => "nginx_logs" 34 | user => "elastic" 35 | password => "changeme" 36 | } 37 | stdout { codec => rubydebug } 38 | } -------------------------------------------------------------------------------- /images/mailhog/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mailhog/mailhog:v1.0.1 -------------------------------------------------------------------------------- /images/mysql/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mysql:8.0.24 2 | 3 | USER mysql 4 | 5 | EXPOSE 3306 -------------------------------------------------------------------------------- /images/mysql/custom.my.cnf: -------------------------------------------------------------------------------- 1 | [mysqld] 2 | # solves General error: 1419 3 | log_bin_trust_function_creators = 1 4 | -------------------------------------------------------------------------------- /images/mysql/init/.gitignore: -------------------------------------------------------------------------------- 1 | . 2 | 3 | !.gitignore -------------------------------------------------------------------------------- /images/mysql/init/custom.sql: -------------------------------------------------------------------------------- 1 | -- You can create new databases here, etc.... 2 | 3 | -- Example: 4 | -- CREATE DATABASE IF NOT EXISTS `another_db`; 5 | -- GRANT ALL ON `another_db`.* TO 'magento'@'%'; -------------------------------------------------------------------------------- /images/nginx/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:1.20.0-alpine 2 | 3 | ARG GROUP_ID 4 | ARG USER_ID 5 | 6 | RUN addgroup -g $GROUP_ID -S dockeruser 7 | 8 | RUN adduser -S -G dockeruser -u $USER_ID -s /bin/ash dockeruser 9 | 10 | RUN chown -R dockeruser:dockeruser /var/cache/nginx 11 | 12 | RUN chmod -R 770 /var/cache/nginx 13 | 14 | RUN touch /var/run/nginx.pid 15 | 16 | RUN chown -R dockeruser:dockeruser /var/run/nginx.pid 17 | 18 | RUN unlink /var/log/nginx/access.log && touch /var/log/nginx/access.log && chown dockeruser /var/log/nginx/access.log 19 | 20 | RUN unlink /var/log/nginx/error.log && touch /var/log/nginx/error.log && chown dockeruser /var/log/nginx/error.log 21 | 22 | USER dockeruser 23 | 24 | WORKDIR /home/dockeruser 25 | -------------------------------------------------------------------------------- /images/nginx/default.conf: -------------------------------------------------------------------------------- 1 | upstream fastcgi_backend { 2 | server php-fpm:9000; 3 | } 4 | 5 | proxy_buffer_size 128k; 6 | proxy_buffers 4 256k; 7 | 8 | server { 9 | server_name "adminer.magento.local"; 10 | 11 | listen 8080; 12 | listen [::]:8080; 13 | 14 | location / { 15 | root /var/www/html; 16 | fastcgi_pass adminer:9000; 17 | include fastcgi_params; 18 | fastcgi_param SCRIPT_FILENAME $document_root/index.php; 19 | } 20 | } 21 | 22 | server { 23 | server_name "kibana.magento.local"; 24 | 25 | listen 8080; 26 | listen [::]:8080; 27 | 28 | location / { 29 | proxy_pass http://kibana:5601; 30 | } 31 | } 32 | 33 | server { 34 | server_name "rabbitmq.magento.local"; 35 | 36 | listen 8080; 37 | listen [::]:8080; 38 | 39 | location / { 40 | proxy_pass http://rabbitmq:15672; 41 | } 42 | } 43 | 44 | server { 45 | server_name "redis.magento.local"; 46 | 47 | listen 8080; 48 | listen [::]:8080; 49 | 50 | location / { 51 | proxy_pass http://redis-admin:8080; 52 | } 53 | } 54 | 55 | server { 56 | server_name "mailhog.magento.local"; 57 | 58 | listen 8080; 59 | listen [::]:8080; 60 | 61 | location / { 62 | proxy_pass http://mailhog:8025; 63 | } 64 | } 65 | 66 | server { 67 | server_name "nuxt.magento.local"; 68 | 69 | listen 8080; 70 | listen [::]:8080; 71 | 72 | location / { 73 | proxy_pass http://node:3000; 74 | } 75 | } 76 | 77 | server { 78 | server_name "magento.local"; 79 | 80 | listen 8080; 81 | listen [::]:8080; 82 | set $MAGE_ROOT /home/dockeruser/magento; 83 | 84 | fastcgi_buffer_size 64k; 85 | fastcgi_buffers 8 128k; 86 | 87 | ## Example configuration: 88 | # upstream fastcgi_backend { 89 | # # use tcp connection 90 | # # server 127.0.0.1:9000; 91 | # # or socket 92 | # server unix:/var/run/php/php7.4-fpm.sock; 93 | # } 94 | # server { 95 | # listen 80; 96 | # server_name mage.dev; 97 | # set $MAGE_ROOT /var/www/magento2; 98 | # set $MAGE_DEBUG_SHOW_ARGS 0; 99 | # include /vagrant/magento2/nginx.conf.sample; 100 | # } 101 | # 102 | ## Optional override of deployment mode. We recommend you use the 103 | ## command 'bin/magento deploy:mode:set' to switch modes instead. 104 | ## 105 | ## set $MAGE_MODE default; # or production or developer 106 | ## 107 | ## If you set MAGE_MODE in server config, you must pass the variable into the 108 | ## PHP entry point blocks, which are indicated below. You can pass 109 | ## it in using: 110 | ## 111 | ## fastcgi_param MAGE_MODE $MAGE_MODE; 112 | ## 113 | ## In production mode, you should uncomment the 'expires' directive in the /static/ location block 114 | 115 | # Modules can be loaded only at the very beginning of the Nginx config file, please move the line below to the main config file 116 | # load_module /etc/nginx/modules/ngx_http_image_filter_module.so; 117 | 118 | root $MAGE_ROOT/pub; 119 | 120 | index index.php; 121 | autoindex off; 122 | charset UTF-8; 123 | error_page 404 403 = /errors/404.php; 124 | #add_header "X-UA-Compatible" "IE=Edge"; 125 | 126 | 127 | # Deny access to sensitive files 128 | location /.user.ini { 129 | deny all; 130 | } 131 | 132 | # PHP entry point for setup application 133 | location ~* ^/setup($|/) { 134 | root $MAGE_ROOT; 135 | location ~ ^/setup/index.php { 136 | fastcgi_pass fastcgi_backend; 137 | 138 | fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off"; 139 | fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=600"; 140 | fastcgi_read_timeout 600s; 141 | fastcgi_connect_timeout 600s; 142 | 143 | fastcgi_index index.php; 144 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 145 | include fastcgi_params; 146 | } 147 | 148 | location ~ ^/setup/(?!pub/). { 149 | deny all; 150 | } 151 | 152 | location ~ ^/setup/pub/ { 153 | add_header X-Frame-Options "SAMEORIGIN"; 154 | } 155 | } 156 | 157 | # PHP entry point for update application 158 | location ~* ^/update($|/) { 159 | root $MAGE_ROOT; 160 | 161 | location ~ ^/update/index.php { 162 | fastcgi_split_path_info ^(/update/index.php)(/.+)$; 163 | fastcgi_pass fastcgi_backend; 164 | fastcgi_index index.php; 165 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 166 | fastcgi_param PATH_INFO $fastcgi_path_info; 167 | include fastcgi_params; 168 | } 169 | 170 | # Deny everything but index.php 171 | location ~ ^/update/(?!pub/). { 172 | deny all; 173 | } 174 | 175 | location ~ ^/update/pub/ { 176 | add_header X-Frame-Options "SAMEORIGIN"; 177 | } 178 | } 179 | 180 | location / { 181 | try_files $uri $uri/ /index.php$is_args$args; 182 | } 183 | 184 | location /pub/ { 185 | location ~ ^/pub/media/(downloadable|customer|import|custom_options|theme_customization/.*\.xml) { 186 | deny all; 187 | } 188 | alias $MAGE_ROOT/pub/; 189 | add_header X-Frame-Options "SAMEORIGIN"; 190 | } 191 | 192 | location /static/ { 193 | # Uncomment the following line in production mode 194 | # expires max; 195 | 196 | # Remove signature of the static files that is used to overcome the browser cache 197 | location ~ ^/static/version { 198 | rewrite ^/static/(version\d*/)?(.*)$ /static/$2 last; 199 | } 200 | 201 | location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2|html|json)$ { 202 | add_header Cache-Control "public"; 203 | add_header X-Frame-Options "SAMEORIGIN"; 204 | expires +1y; 205 | 206 | if (!-f $request_filename) { 207 | rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; 208 | } 209 | } 210 | location ~* \.(zip|gz|gzip|bz2|csv|xml)$ { 211 | add_header Cache-Control "no-store"; 212 | add_header X-Frame-Options "SAMEORIGIN"; 213 | expires off; 214 | 215 | if (!-f $request_filename) { 216 | rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; 217 | } 218 | } 219 | if (!-f $request_filename) { 220 | rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; 221 | } 222 | add_header X-Frame-Options "SAMEORIGIN"; 223 | } 224 | 225 | location /media/ { 226 | 227 | ## The following section allows to offload image resizing from Magento instance to the Nginx. 228 | ## Catalog image URL format should be set accordingly. 229 | ## See https://docs.magento.com/user-guide/configuration/general/web.html#url-options 230 | # location ~* ^/media/catalog/.* { 231 | # 232 | # # Replace placeholders and uncomment the line below to serve product images from public S3 233 | # # See examples of S3 authentication at https://github.com/anomalizer/ngx_aws_auth 234 | # # resolver 8.8.8.8; 235 | # # proxy_pass https://..amazonaws.com; 236 | # 237 | # set $width "-"; 238 | # set $height "-"; 239 | # if ($arg_width != '') { 240 | # set $width $arg_width; 241 | # } 242 | # if ($arg_height != '') { 243 | # set $height $arg_height; 244 | # } 245 | # image_filter resize $width $height; 246 | # image_filter_jpeg_quality 90; 247 | # } 248 | 249 | try_files $uri $uri/ /get.php$is_args$args; 250 | 251 | location ~ ^/media/theme_customization/.*\.xml { 252 | deny all; 253 | } 254 | 255 | location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ { 256 | add_header Cache-Control "public"; 257 | add_header X-Frame-Options "SAMEORIGIN"; 258 | expires +1y; 259 | try_files $uri $uri/ /get.php$is_args$args; 260 | } 261 | location ~* \.(zip|gz|gzip|bz2|csv|xml)$ { 262 | add_header Cache-Control "no-store"; 263 | add_header X-Frame-Options "SAMEORIGIN"; 264 | expires off; 265 | try_files $uri $uri/ /get.php$is_args$args; 266 | } 267 | add_header X-Frame-Options "SAMEORIGIN"; 268 | } 269 | 270 | location /media/customer/ { 271 | deny all; 272 | } 273 | 274 | location /media/downloadable/ { 275 | deny all; 276 | } 277 | 278 | location /media/import/ { 279 | deny all; 280 | } 281 | 282 | location /media/custom_options/ { 283 | deny all; 284 | } 285 | 286 | location /errors/ { 287 | location ~* \.xml$ { 288 | deny all; 289 | } 290 | } 291 | 292 | # PHP entry point for main application 293 | location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check)\.php$ { 294 | try_files $uri =404; 295 | fastcgi_pass fastcgi_backend; 296 | fastcgi_buffers 16 16k; 297 | fastcgi_buffer_size 32k; 298 | 299 | fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off"; 300 | fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=18000"; 301 | fastcgi_read_timeout 600s; 302 | fastcgi_connect_timeout 600s; 303 | 304 | fastcgi_index index.php; 305 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 306 | include fastcgi_params; 307 | } 308 | 309 | gzip on; 310 | gzip_disable "msie6"; 311 | 312 | gzip_comp_level 6; 313 | gzip_min_length 1100; 314 | gzip_buffers 16 8k; 315 | gzip_proxied any; 316 | gzip_types 317 | text/plain 318 | text/css 319 | text/js 320 | text/xml 321 | text/javascript 322 | application/javascript 323 | application/x-javascript 324 | application/json 325 | application/xml 326 | application/xml+rss 327 | image/svg+xml; 328 | gzip_vary on; 329 | 330 | # Banned locations (only reached if the earlier PHP entry point regexes don't match) 331 | location ~* (\.php$|\.phtml$|\.htaccess$|\.git) { 332 | deny all; 333 | } 334 | } 335 | 336 | server { 337 | server_name ""; 338 | 339 | listen 8080 default_server; 340 | listen [::]:8080 default_server; 341 | set $MAGE_ROOT /home/dockeruser/magento; 342 | 343 | root $MAGE_ROOT/pub; 344 | 345 | fastcgi_buffer_size 64k; 346 | fastcgi_buffers 8 128k; 347 | 348 | index index.php; 349 | autoindex off; 350 | charset UTF-8; 351 | error_page 404 403 = /errors/404.php; 352 | #add_header "X-UA-Compatible" "IE=Edge"; 353 | 354 | location / { 355 | try_files $uri $uri/ /index.php$is_args$args; 356 | } 357 | 358 | # PHP entry point for main application 359 | location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check)\.php$ { 360 | try_files $uri =404; 361 | fastcgi_pass fastcgi_backend; 362 | fastcgi_buffers 16 16k; 363 | fastcgi_buffer_size 32k; 364 | 365 | fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off"; 366 | fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=18000"; 367 | fastcgi_read_timeout 600s; 368 | fastcgi_connect_timeout 600s; 369 | 370 | fastcgi_index index.php; 371 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 372 | include fastcgi_params; 373 | } 374 | } 375 | -------------------------------------------------------------------------------- /images/node/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:16-alpine3.14 2 | 3 | ARG GROUP_ID 4 | ARG USER_ID 5 | 6 | RUN apk update && apk upgrade; 7 | 8 | RUN apk --no-cache add shadow; 9 | 10 | RUN groupmod -g $GROUP_ID node 11 | RUN usermod -u $USER_ID -g $GROUP_ID node 12 | 13 | RUN find / -group $GROUP_ID -exec chgrp -h node {} \; 14 | RUN find / -user $USER_ID -exec chown -h node {} \; 15 | 16 | RUN yarn global add @vue/cli 17 | 18 | USER node 19 | 20 | WORKDIR /home/node 21 | 22 | EXPOSE 3000 -------------------------------------------------------------------------------- /images/php-fpm/.composer/.placeholder: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ironexdev/docker-magento/e69e1884533ca0d6af4d0524b80915f5e687164d/images/php-fpm/.composer/.placeholder -------------------------------------------------------------------------------- /images/php-fpm/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.4.19-fpm-alpine 2 | 3 | ARG DOCKER_IMAGE_FOLDER 4 | ARG GROUP_ID 5 | ARG USER_ID 6 | 7 | # iconv fix (https://github.com/docker-library/php/issues/240#issuecomment-763112749) 8 | RUN apk add --upgrade gnu-libiconv 9 | ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so 10 | 11 | # php gd dependencies 12 | RUN apk add zlib-dev 13 | RUN apk add jpeg-dev 14 | RUN apk add libpng-dev 15 | RUN apk add freetype-dev 16 | 17 | # php intl dependencies 18 | RUN apk add icu-dev 19 | 20 | # php soap dependencies 21 | RUN apk add libxml2-dev 22 | 23 | # php xsl dependencies 24 | RUN apk add libxslt-dev 25 | 26 | # php zip dependencies 27 | RUN apk add libzip-dev 28 | 29 | RUN docker-php-ext-install mysqli 30 | RUN docker-php-ext-install pdo_mysql 31 | RUN docker-php-ext-install bcmath 32 | RUN docker-php-ext-configure gd --with-freetype --with-jpeg 33 | RUN docker-php-ext-install gd 34 | RUN docker-php-ext-install intl 35 | RUN docker-php-ext-install soap 36 | RUN docker-php-ext-install xsl 37 | RUN docker-php-ext-install zip 38 | RUN docker-php-ext-install sockets 39 | 40 | # Xdebug 41 | RUN apk add --no-cache $PHPIZE_DEPS \ 42 | && pecl install xdebug-3.0.4 \ 43 | && docker-php-ext-enable xdebug 44 | 45 | COPY $DOCKER_IMAGE_FOLDER/php-fpm/php.ini /usr/local/etc/php/php.ini 46 | 47 | # Git 48 | RUN apk add git 49 | 50 | # Composer 51 | RUN apk add composer 52 | 53 | RUN addgroup -g $GROUP_ID -S dockeruser 54 | 55 | RUN adduser -S -G dockeruser -u $USER_ID -s /bin/ash dockeruser 56 | 57 | RUN chown -R dockeruser: /usr/local/etc/php 58 | 59 | USER dockeruser 60 | 61 | WORKDIR /home/dockeruser/magento 62 | 63 | EXPOSE 9000 64 | -------------------------------------------------------------------------------- /images/php-fpm/custom-php.ini: -------------------------------------------------------------------------------- 1 | ; php.ini customization, feel free to edit 2 | -------------------------------------------------------------------------------- /images/php-fpm/php.ini: -------------------------------------------------------------------------------- 1 | ; do not edit, used during image build 2 | [php] 3 | memory_limit = 2G 4 | max_execution_time = 1800 5 | zlib.output_compression = On 6 | cgi.fix_pathinfo = 0 7 | date.timezone = UTC 8 | upload_max_filesize = 100M 9 | post_max_size = 100M 10 | max_input_vars = 10000 11 | 12 | [xdebug] 13 | xdebug.mode=off 14 | xdebug.client_host="host.docker.internal" 15 | xdebug.start_with_request=yes 16 | xdebug.discover_client_host = 1 17 | 18 | [mail] 19 | sendmail_path = /usr/sbin/sendmail -S mailhog:1025 20 | -------------------------------------------------------------------------------- /images/rabbitmq/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM rabbitmq:3.8.16-management-alpine 2 | 3 | USER rabbitmq -------------------------------------------------------------------------------- /images/redis-admin/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM erikdubbelboer/phpredisadmin:v1.13.2 2 | 3 | RUN chown www-data:www-data -R /src 4 | 5 | RUN chmod 770 /src 6 | 7 | USER www-data 8 | 9 | EXPOSE 8080 10 | 11 | ENTRYPOINT ["tini","--","php","-S","0.0.0.0:8080"] -------------------------------------------------------------------------------- /images/redis/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM redis:6.2.3-alpine 2 | 3 | USER redis --------------------------------------------------------------------------------