├── .docker ├── .project-env.dist ├── database │ ├── Dockerfile │ ├── data │ │ └── .gitkeep │ └── setup │ │ └── 20170111114749-Magento-21-Default-Schema.sql ├── nginx │ ├── Dockerfile │ ├── conf │ │ ├── nginx.conf │ │ └── upstream.conf │ └── sites-enabled │ │ └── project.conf └── php │ ├── Dockerfile │ ├── conf │ ├── php.ini │ ├── project.pool.conf │ └── xdebug.ini │ └── logs │ └── .gitkeep ├── LICENSE.txt ├── README.md └── docker-compose.yml /.docker/.project-env.dist: -------------------------------------------------------------------------------- 1 | MYSQL_ROOT_PASSWORD=root_pass_here 2 | MYSQL_DATABASE=project_db 3 | MYSQL_USER=user_name_here 4 | MYSQL_PASSWORD=user_passphrase_here 5 | 6 | XDEBUG_PORT=9000 -------------------------------------------------------------------------------- /.docker/database/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mysql:5.7 2 | 3 | MAINTAINER Denis-Florin Rendler 4 | 5 | EXPOSE 3306 -------------------------------------------------------------------------------- /.docker/database/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evozon/magento2-docker/3e44004e8ba82d61d800c3e691b904ff37f97455/.docker/database/data/.gitkeep -------------------------------------------------------------------------------- /.docker/nginx/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:latest 2 | 3 | MAINTAINER Denis-Florin Rendler 4 | 5 | EXPOSE 80 443 6 | 7 | VOLUME ["/etc/nginx/conf.d", "/etc/nginx/sites-enabled", "/var/log/nginx/log"] -------------------------------------------------------------------------------- /.docker/nginx/conf/nginx.conf: -------------------------------------------------------------------------------- 1 | user nginx; 2 | worker_processes 1; 3 | 4 | error_log /var/log/nginx/error.log warn; 5 | pid /var/run/nginx.pid; 6 | 7 | events { 8 | worker_connections 1024; 9 | } 10 | 11 | http { 12 | include /etc/nginx/mime.types; 13 | default_type application/octet-stream; 14 | 15 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 16 | '$status $body_bytes_sent "$http_referer" ' 17 | '"$http_user_agent" "$http_x_forwarded_for"'; 18 | 19 | access_log /var/log/nginx/access.log main; 20 | 21 | sendfile on; 22 | #tcp_nopush on; 23 | 24 | keepalive_timeout 65; 25 | 26 | #gzip on; 27 | 28 | include /etc/nginx/conf.d/*.conf; 29 | include /etc/nginx/sites-enabled/*.conf; 30 | } -------------------------------------------------------------------------------- /.docker/nginx/conf/upstream.conf: -------------------------------------------------------------------------------- 1 | upstream php-upstream 2 | { 3 | server php:9000; 4 | } -------------------------------------------------------------------------------- /.docker/nginx/sites-enabled/project.conf: -------------------------------------------------------------------------------- 1 | upstream fastcgi_backend { 2 | # use tcp connection 3 | server php:9000; 4 | } 5 | 6 | server { 7 | listen 80; 8 | server_name project-mage.dev; 9 | 10 | set $MAGE_ROOT /www/project; 11 | 12 | root $MAGE_ROOT/pub; 13 | 14 | index index.php; 15 | autoindex off; 16 | charset UTF-8; 17 | error_page 404 403 = /errors/404.php; 18 | #add_header "X-UA-Compatible" "IE=Edge"; 19 | 20 | # PHP entry point for setup application 21 | location ~* ^/setup($|/) { 22 | root $MAGE_ROOT; 23 | location ~ ^/setup/index.php { 24 | fastcgi_pass fastcgi_backend; 25 | fastcgi_index index.php; 26 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 27 | include fastcgi_params; 28 | } 29 | 30 | location ~ ^/setup/(?!pub/). { 31 | deny all; 32 | } 33 | 34 | location ~ ^/setup/pub/ { 35 | add_header X-Frame-Options "SAMEORIGIN"; 36 | } 37 | } 38 | 39 | # PHP entry point for update application 40 | location ~* ^/update($|/) { 41 | root $MAGE_ROOT; 42 | 43 | location ~ ^/update/index.php { 44 | fastcgi_split_path_info ^(/update/index.php)(/.+)$; 45 | fastcgi_pass fastcgi_backend; 46 | fastcgi_index index.php; 47 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 48 | fastcgi_param PATH_INFO $fastcgi_path_info; 49 | include fastcgi_params; 50 | } 51 | 52 | # Deny everything but index.php 53 | location ~ ^/update/(?!pub/). { 54 | deny all; 55 | } 56 | 57 | location ~ ^/update/pub/ { 58 | add_header X-Frame-Options "SAMEORIGIN"; 59 | } 60 | } 61 | 62 | location / { 63 | try_files $uri $uri/ /index.php?$args; 64 | } 65 | 66 | location /pub/ { 67 | location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml) { 68 | deny all; 69 | } 70 | alias $MAGE_ROOT/pub/; 71 | add_header X-Frame-Options "SAMEORIGIN"; 72 | } 73 | 74 | location /static/ { 75 | # Uncomment the following line in production mode 76 | # expires max; 77 | 78 | # Remove signature of the static files that is used to overcome the browser cache 79 | location ~ ^/static/version { 80 | rewrite ^/static/(version\d*/)?(.*)$ /static/$2 last; 81 | } 82 | 83 | location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ { 84 | add_header Cache-Control "public"; 85 | add_header X-Frame-Options "SAMEORIGIN"; 86 | expires +1y; 87 | 88 | if (!-f $request_filename) { 89 | rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; 90 | } 91 | } 92 | location ~* \.(zip|gz|gzip|bz2|csv|xml)$ { 93 | add_header Cache-Control "no-store"; 94 | add_header X-Frame-Options "SAMEORIGIN"; 95 | expires off; 96 | 97 | if (!-f $request_filename) { 98 | rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; 99 | } 100 | } 101 | if (!-f $request_filename) { 102 | rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; 103 | } 104 | add_header X-Frame-Options "SAMEORIGIN"; 105 | } 106 | 107 | location /media/ { 108 | try_files $uri $uri/ /get.php?$args; 109 | 110 | location ~ ^/media/theme_customization/.*\.xml { 111 | deny all; 112 | } 113 | 114 | location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ { 115 | add_header Cache-Control "public"; 116 | add_header X-Frame-Options "SAMEORIGIN"; 117 | expires +1y; 118 | try_files $uri $uri/ /get.php?$args; 119 | } 120 | location ~* \.(zip|gz|gzip|bz2|csv|xml)$ { 121 | add_header Cache-Control "no-store"; 122 | add_header X-Frame-Options "SAMEORIGIN"; 123 | expires off; 124 | try_files $uri $uri/ /get.php?$args; 125 | } 126 | add_header X-Frame-Options "SAMEORIGIN"; 127 | } 128 | 129 | location /media/customer/ { 130 | deny all; 131 | } 132 | 133 | location /media/downloadable/ { 134 | deny all; 135 | } 136 | 137 | location /media/import/ { 138 | deny all; 139 | } 140 | 141 | # PHP entry point for main application 142 | location ~ (index|get|static|report|404|503)\.php$ { 143 | try_files $uri =404; 144 | fastcgi_pass fastcgi_backend; 145 | fastcgi_buffers 1024 4k; 146 | 147 | fastcgi_read_timeout 600s; 148 | fastcgi_connect_timeout 600s; 149 | 150 | fastcgi_index index.php; 151 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 152 | include fastcgi_params; 153 | } 154 | 155 | gzip on; 156 | gzip_disable "msie6"; 157 | 158 | gzip_comp_level 6; 159 | gzip_min_length 1100; 160 | gzip_buffers 16 8k; 161 | gzip_proxied any; 162 | gzip_types 163 | text/plain 164 | text/css 165 | text/js 166 | text/xml 167 | text/javascript 168 | application/javascript 169 | application/x-javascript 170 | application/json 171 | application/xml 172 | application/xml+rss 173 | image/svg+xml; 174 | gzip_vary on; 175 | 176 | # Banned locations (only reached if the earlier PHP entry point regexes don't match) 177 | location ~* (\.php$|\.htaccess$|\.git) { 178 | deny all; 179 | } 180 | } -------------------------------------------------------------------------------- /.docker/php/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.0-fpm 2 | 3 | MAINTAINER Denis-Florin Rendler 4 | 5 | # install some bare necessities 6 | RUN apt-get update && apt-get install -y \ 7 | libssl-dev \ 8 | libmcrypt-dev \ 9 | libjpeg62-turbo-dev \ 10 | libpng12-dev \ 11 | libfreetype6-dev \ 12 | libpq-dev \ 13 | zlib1g-dev \ 14 | libicu-dev \ 15 | libxslt-dev \ 16 | curl \ 17 | ssh \ 18 | vim \ 19 | git \ 20 | openssl \ 21 | g++ \ 22 | --no-install-recommends \ 23 | && rm -r /var/lib/apt/lists/* 24 | 25 | # configure libraries 26 | RUN docker-php-ext-configure gd \ 27 | --enable-gd-native-ttf \ 28 | --with-freetype-dir=/usr/include/freetype2 \ 29 | --with-jpeg-dir=/usr/lib/x86_64-linux-gnu/ \ 30 | && docker-php-ext-configure intl \ 31 | && docker-php-ext-configure hash --with-mhash 32 | 33 | # install required extensions 34 | RUN docker-php-ext-install \ 35 | bcmath \ 36 | gd \ 37 | intl \ 38 | mcrypt \ 39 | pdo_mysql \ 40 | xsl \ 41 | zip \ 42 | json \ 43 | iconv \ 44 | soap 45 | 46 | # add XDebug for the dev env build 47 | RUN pecl install xdebug \ 48 | && docker-php-ext-enable xdebug 49 | 50 | # expose the xdebug port on dev build 51 | ENV XDEBUG_EXPOSE_PORT ${XDEBUG_PORT:-9000} 52 | EXPOSE $XDEBUG_EXPOSE_PORT 53 | 54 | # configure app folder 55 | ENV WORK_DIR ${WORK_DIR:-/www/project} 56 | WORKDIR $WORK_DIR 57 | 58 | # Install Composer 59 | RUN curl -s http://getcomposer.org/installer | php \ 60 | && mv composer.phar /usr/local/bin/composer 61 | 62 | VOLUME "/usr/local/etc/php/conf.d" 63 | -------------------------------------------------------------------------------- /.docker/php/conf/php.ini: -------------------------------------------------------------------------------- 1 | memory_limit=512M -------------------------------------------------------------------------------- /.docker/php/conf/project.pool.conf: -------------------------------------------------------------------------------- 1 | ; Unix user/group of processes 2 | ; Note: The user is mandatory. If the group is not set, the default user's group 3 | ; will be used. 4 | user = www-data 5 | group = www-data 6 | 7 | ; The address on which to accept FastCGI requests. 8 | ; Valid syntaxes are: 9 | ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on 10 | ; a specific port; 11 | ; 'port' - to listen on a TCP socket to all addresses on a 12 | ; specific port; 13 | ; '/path/to/unix/socket' - to listen on a unix socket. 14 | ; Note: This value is mandatory. 15 | listen = 0.0.0.0:9000 16 | 17 | ; Choose how the process manager will control the number of child processes. 18 | ; Possible Values: 19 | ; static - a fixed number (pm.max_children) of child processes; 20 | ; dynamic - the number of child processes are set dynamically based on the 21 | ; following directives. With this process management, there will be 22 | ; always at least 1 children. 23 | ; pm.max_children - the maximum number of children that can 24 | ; be alive at the same time. 25 | ; pm.start_servers - the number of children created on startup. 26 | ; pm.min_spare_servers - the minimum number of children in 'idle' 27 | ; state (waiting to process). If the number 28 | ; of 'idle' processes is less than this 29 | ; number then some children will be created. 30 | ; pm.max_spare_servers - the maximum number of children in 'idle' 31 | ; state (waiting to process). If the number 32 | ; of 'idle' processes is greater than this 33 | ; number then some children will be killed. 34 | ; ondemand - no children are created at startup. Children will be forked when 35 | ; new requests will connect. The following parameter are used: 36 | ; pm.max_children - the maximum number of children that 37 | ; can be alive at the same time. 38 | ; pm.process_idle_timeout - The number of seconds after which 39 | ; an idle process will be killed. 40 | ; Note: This value is mandatory. 41 | pm = dynamic 42 | 43 | ; The number of child processes to be created when pm is set to 'static' and the 44 | ; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. 45 | ; This value sets the limit on the number of simultaneous requests that will be 46 | ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. 47 | ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP 48 | ; CGI. The below defaults are based on a server without much resources. Don't 49 | ; forget to tweak pm.* to fit your needs. 50 | ; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' 51 | ; Note: This value is mandatory. 52 | pm.max_children = 20 53 | 54 | ; The number of child processes created on startup. 55 | ; Note: Used only when pm is set to 'dynamic' 56 | ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 57 | pm.start_servers = 5 58 | 59 | ; The desired minimum number of idle server processes. 60 | ; Note: Used only when pm is set to 'dynamic' 61 | ; Note: Mandatory when pm is set to 'dynamic' 62 | pm.min_spare_servers = 3 63 | 64 | ; The desired maximum number of idle server processes. 65 | ; Note: Used only when pm is set to 'dynamic' 66 | ; Note: Mandatory when pm is set to 'dynamic' 67 | pm.max_spare_servers = 5 68 | 69 | ;--------------------- 70 | 71 | ; Make specific Docker environment variables available to PHP 72 | 73 | catch_workers_output = yes -------------------------------------------------------------------------------- /.docker/php/conf/xdebug.ini: -------------------------------------------------------------------------------- 1 | xdebug.remote_autostart=1 2 | xdebug.remote_enable=1 3 | xdebug.remote_handler=dbgp 4 | xdebug.remote_mode=req 5 | xdebug.remote_port=9000 6 | xdebug.idekey="PHPSTORM" 7 | xdebug.remote_host=10.0.75.1 8 | ;xdebug.remote_log=/usr/local/var/log/xdebug.log 9 | -------------------------------------------------------------------------------- /.docker/php/logs/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evozon/magento2-docker/3e44004e8ba82d61d800c3e691b904ff37f97455/.docker/php/logs/.gitkeep -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2017 Evozon Systems 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), 4 | to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 5 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 10 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 11 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker bootstrap project for Magento 2 2 | This is a Docker bootstrap project intended for quick and easy Magento 2 development start. 3 | 4 | NOTE: This repository is part of the article: https://magento.evozon.com/using-docker-for-magento-2-development.html 5 | 6 | # Usage 7 | 1. clone repository 8 | 2. run `mv .docker/.project-env.dist .project-env` 9 | 3. update `/.project-env` with your project's environment variables 10 | 4. run `docker-compose up -d` 11 | 12 | 13 | # LICENSE 14 | License is MIT. 15 | For additional information on the license please review the LICENSE.txt file attached. 16 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | services: 4 | nginx: 5 | build: 6 | context: .docker/nginx 7 | 8 | image: project/magento-nginx 9 | 10 | container_name: project_magento2_nginx 11 | 12 | volumes: 13 | - ./.docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf 14 | - ./.docker/nginx/conf/upstream.conf:/etc/nginx/conf.d/upstream.conf 15 | - ./.docker/nginx/sites-enabled:/etc/nginx/sites-enabled 16 | - ./:/www/project 17 | 18 | ports: 19 | - 80:80 20 | - 443:443 21 | 22 | links: 23 | - php 24 | 25 | tty: true 26 | 27 | env_file: 28 | - ./.project-env 29 | 30 | php: 31 | build: 32 | context: .docker/php 33 | 34 | image: project/magento-php 35 | 36 | container_name: project_magento2_php 37 | 38 | volumes: 39 | - ./.docker/php/conf/php.ini:/usr/local/etc/php/php.ini 40 | - ./.docker/php/conf/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini 41 | - ./.docker/php/conf/project.pool.conf:/usr/local/etc/php-fpm.d/www.conf 42 | - ./.docker/php/logs:/usr/local/var/log 43 | - ./:/www/project 44 | 45 | ports: 46 | - "9001:9000" 47 | 48 | links: 49 | - database 50 | 51 | tty: true 52 | 53 | env_file: 54 | - ./.project-env 55 | 56 | environment: 57 | PHP_IDE_CONFIG: "serverName=project" 58 | 59 | database: 60 | build: 61 | context: .docker/database 62 | 63 | image: project/magento-database 64 | 65 | container_name: project_magento2_db 66 | 67 | volumes: 68 | - ./.docker/database/data:/var/lib/mysql 69 | - ./.docker/database/setup:/docker-entrypoint-initdb.d 70 | 71 | ports: 72 | - 3307:3306 73 | 74 | tty: true 75 | 76 | env_file: 77 | - ./.project-env --------------------------------------------------------------------------------