├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── composer.json ├── config ├── installer │ ├── bin │ │ ├── install.sh │ │ └── substitute-env-vars.sh │ ├── magento │ │ ├── fpc.xml.tmpl │ │ └── local.xml.tmpl │ ├── magerun │ │ └── n98-magerun.yaml.tmpl │ └── php │ │ └── php.ini ├── nginx │ ├── custom-locations │ │ └── custom.location │ ├── includes │ │ ├── api │ │ ├── fastcgi │ │ ├── gzip │ │ └── minify │ ├── nginx.conf │ └── sites-enabled │ │ └── default.conf └── ssl │ ├── cert.csr │ ├── cert.key │ └── cert.pem ├── data └── .gitignore ├── docker-compose.yml ├── docker-images ├── installer │ └── Dockerfile ├── nginx │ ├── Dockerfile │ ├── bin │ │ ├── entrypoint.sh │ │ └── substitute-env-vars.sh │ ├── nginx.conf │ └── sites-templates │ │ └── default.conf.tmpl ├── php │ ├── Dockerfile │ ├── ext-xdebug.ini │ ├── php-fpm.conf │ └── php.ini └── solr │ ├── Dockerfile │ └── conf │ ├── schema.xml │ └── solrconfig.xml ├── documentation ├── dockerized-magento-component-diagram.png ├── dockerized-magento-component-diagram.svg └── installation-and-first-start-animation.gif ├── logs └── .gitignore └── magento /.gitignore: -------------------------------------------------------------------------------- 1 | web 2 | composer.lock 3 | composer.phar 4 | vendor 5 | db 6 | .vagrant 7 | .DS_Store 8 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](http://keepachangelog.com/) 5 | and this project adheres to [Semantic Versioning](http://semver.org/). 6 | 7 | 8 | ## [Unreleased] 9 | 10 | ### Added 11 | - Add a phyMyAdmin container 12 | 13 | ### Changed 14 | - Update AOE Scheduler to version "^1" 15 | - Reference major versions for SMTP Pro, Lesti FPC, Magento Core, AOE Template hints and Scope Hint 16 | 17 | ## [v0.11.0] - 2016-11-09 18 | 19 | ### Changed 20 | - Allow access to the Magento Connect Manager (see issue #29) 21 | - Move the scope hint and qconfig modules to the normal requirements (see pull request #27) 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Andreas Koch "Andyk" 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dockerized - Magento Community Edition 1.9.x 2 | 3 | A dockerized version of "Magento Community Edition 1.9.x" 4 | 5 | ## Requirements 6 | 7 | If you are on Linux you should install 8 | 9 | - [docker](http://docs.docker.com/compose/install/#install-docker) and 10 | - [docker-compose (formerly known as fig)](http://docs.docker.com/compose/install/#install-compose) 11 | 12 | If you are running on [Mac OS](https://docs.docker.com/engine/installation/mac/) or [Windows](https://docs.docker.com/engine/installation/windows/) you can install the [Docker Toolbox](https://docs.docker.com/engine/installation/mac/) which contains docker, docker-compose and docker-machine. 13 | 14 | ## Preparations 15 | 16 | The web-server will be bound to your local ports 80 and 443. In order to access the shop you must add a hosts file entry for `dockerized-magento.local`. 17 | 18 | ### For Linux Users 19 | 20 | In order to access the shop you must add the domain name "dockerized-magento.local" to your hosts file (`/etc/hosts`). 21 | If you are using docker **natively** you can use this command: 22 | 23 | ```bash 24 | sudo su 25 | echo "127.0.0.1 dockerized-magento.local" >> /etc/hosts 26 | ``` 27 | 28 | ### For Mac Users 29 | 30 | If you are using [docker-machine](https://github.com/docker/machine) you need to use the IP address of your virtual machine running docker: 31 | 32 | ```bash 33 | docker-machine ls 34 | docker-machine ip 35 | ``` 36 | 37 | ```bash 38 | echo "192.168.99.100 dockerized-magento.local" >> /etc/hosts 39 | ``` 40 | 41 | **docker-machine performance** 42 | 43 | For faster sync between your host system and the docker machine image I recommend that you activate NFS support for virtualbox: [github.com/adlogix/docker-machine-nfs](https://github.com/adlogix/docker-machine-nfs) 44 | 45 | ```bash 46 | docker-machine create --driver virtualbox nfsbox 47 | docker-machine-nfs nfsbox 48 | ``` 49 | 50 | And to fix issues with filesystem permissions you can modify your NFS exports configuration: 51 | 52 | 1. open `/etc/exports` and replace `-mapall=$uid:$gid` with `-maproot=0` 53 | 2. `sudo nfsd restart` 54 | 55 | Thanks to [René Penner](https://github.com/renepenner/magento-docker-boilerplate) for figuring that out. 56 | 57 | ### For Windows Users 58 | 59 | I suppose it will work on Windows, but I have not tested it. And I suspect that the performance will not be great due to the slow file-sharing protocol between the Windows hosts and the VirtualBox VM. 60 | 61 | ## Installation 62 | 63 | 1. Make sure you have docker and docker-compose on your system 64 | 2. Clone the repository 65 | 3. Start the projects using `./magento start` or `docker-compose up` 66 | 67 | ```bash 68 | git clone https://github.com/andreaskoch/dockerized-magento.git && cd dockerized-magento 69 | ./magento start 70 | ``` 71 | 72 | During the first start of the project **docker-compose** will 73 | 74 | 1. first **build** all docker-images referenced in the [docker-compose.yml](docker-compose.yml) 75 | 2. then **start** the containers 76 | 3. and **trigger the installer** which will 77 | - [install magento](docker-images/installer/bin/install.sh) and all modules that are referenced in the [composer.json](composer.json) using `composer` into the web folder 78 | - download the [Magento Demo Store Sample Data](http://www.magentocommerce.com/knowledge-base/entry/installing-the-sample-data-for-magento) 79 | - copy the files to the magento-root 80 | - import the sample database 81 | - and finally reindex all indices 82 | 83 | Once the installation is finished the installer will print the URL and the credentials for the backend to the installer log: 84 | 85 | ``` 86 | ... 87 | installer_1 | phpMyAdmin: http://dockerized-magento.local:8080 88 | installer_1 | - Username: root 89 | installer_1 | - Password: pw 90 | installer_1 | 91 | installer_1 | Backend: http://dockerized-magento.local/admin 92 | installer_1 | - Username: admin 93 | installer_1 | - Password: password123 94 | installer_1 | 95 | installer_1 | Frontend: http://dockerized-magento.local/ 96 | 97 | ``` 98 | 99 | [![Animation: Installation and first project start](documentation/installation-and-first-start-animation.gif)](https://s3.amazonaws.com/andreaskoch/dockerized-magento/installation/Dockerized-Magento-Installation-Linux-no-sound.mp4) 100 | 101 | **Note**: The build process and the installation process will take a while if you start the project for the first time. After that, starting and stoping the project will be a matter of seconds. 102 | 103 | ## Usage 104 | 105 | You can control the project using the built-in `magento`-script which is basically just a **wrapper for docker and docker-compose** that offers some **convenience features**: 106 | 107 | ```bash 108 | ./magento 109 | ``` 110 | 111 | **Available Actons** 112 | 113 | - **start**: Starts the docker containers (and triggers the installation if magento is not yet installed) 114 | - **stop**: Stops all docker containers 115 | - **restart**: Restarts all docker containers and flushes the cache 116 | - **status**: Prints the status of all docker containers 117 | - **stats**: Displays live resource usage statistics of all containers 118 | - **magerun**: Executes magerun in the magento root directory 119 | - **composer**: Executes composer in the magento root directory 120 | - **enter**: Enters the bash of a given container type (e.g. php, mysql, ...) 121 | - **destroy**: Stops all containers and removes all data 122 | 123 | **Note**: The `magento`-script is just a small wrapper around `docker-compose`. You can just use [docker-compose](https://docs.docker.com/compose/) directly. 124 | 125 | ## Components 126 | 127 | ### Overview 128 | 129 | The dockerized Magento project consists of the following components: 130 | 131 | - **[docker images](docker-images)** 132 | 1. a [PHP](docker-images/php/Dockerfile) image 133 | 2. a [Nginx](docker-images/nginx/Dockerfile) web server image 134 | 3. a [Solr](docker-images/solr/Dockerfile) search server 135 | 4. a standard [MySQL](https://hub.docker.com/_/mysql/) database server image 136 | 5. multiple instances of the standard [Redis](https://hub.docker.com/_/redis/) docker image 137 | 6. a standard [phpMyAdmin](https://hub.docker.com/r/phpmyadmin/phpmyadmin/) image that allows you to access the database on port 8080 138 | 7. and a [Installer](docker-images/installer/Dockerfile) image which contains all tools for installing the project from scratch using an [install script](docker-images/installer/bin/install.sh) 139 | - a **[shell script](magento)** for controlling the project: [`./magento `](magento) 140 | - a [composer-file](composer.json) for managing the **Magento modules** 141 | - and the [docker-compose.yml](docker-compose.yml)-file which connects all components 142 | 143 | The component-diagram should give you a general idea* how all components of the "dockerized Magento" project are connected: 144 | 145 | [![Dockerized Magento: Component Diagram](documentation/dockerized-magento-component-diagram.png)](documentation/dockerized-magento-component-diagram.svg) 146 | 147 | `*` The diagram is just an attempt to visualize the dependencies between the different components. You can get the complete picture by studying the docker-compose file: [docker-compose.yml](docker-compose.yml) 148 | 149 | Even though the setup might seem complex, the usage is thanks to docker really easy. 150 | 151 | If you are interested in a **guide on how to dockerize a Magento** shop yourself you can have a look at a blog-post of mine: [Dockerizing Magento](https://andykdocs.de/development/Docker/Dockerize-Magento) on [AndyK Docs](https://andykdocs.de) 152 | 153 | ## Custom Configuration 154 | 155 | All parameters of the Magento installation are defined via environment variables that are set in the [docker-compose.yml](docker-compose.yml) file - if you want to tailor the Magento Shop installation to your needs you can do so **by modifying the environment variables** before you start the project. 156 | 157 | If you have started the shop before you must **repeat the installation process** in order to apply changes: 158 | 159 | 1. Modify the parameters in the `docker-compose.yml` 160 | 2. Shutdown the containers and remove all data (`./magento destroy`) 161 | 3. Start the containers again (`./magento start`) 162 | 163 | ### Changing the domain name 164 | 165 | I set the default domain name to `dockerized-magento.local`. To change the domain name replace `dockerized-magento.local` with `your-domain.tld` in the `docker-compose.yml` file: 166 | 167 | ```yaml 168 | installer: 169 | environment: 170 | DOMAIN: dockerized-magento.local 171 | ``` 172 | 173 | ### Using a different SSL certificate 174 | 175 | By default I chose a dummy certificate ([config/ssl/cert.pem](config/ssl/cert.pem)). 176 | If you want to use a different certificate you can just override the key and cert with your own certificates. 177 | 178 | ### Adapt Magento Installation Parameters 179 | 180 | If you want to install Magento using your own admin-user or change the password, email-adreess or name you can change the environment variable of the **installer** that begin with `ADMIN_`: 181 | 182 | - `ADMIN_USERNAME`: The username of the admin user 183 | - `ADMIN_FIRSTNAME`: The first name of the admin user 184 | - `ADMIN_LASTNAME`: The last name of the admin user 185 | - `ADMIN_PASSWORD`: The password for the admin user 186 | - `ADMIN_EMAIL`: The email address of the admin user (**Note**: Make sure it has a valid syntax. Otherwise Magento will not install.) 187 | - `ADMIN_FRONTNAME`: The name of the backend route (e.g. `http://dockerized-magento.local/admin`) 188 | 189 | ```yaml 190 | installer: 191 | build: docker-images/installer 192 | environment: 193 | ADMIN_USERNAME: admin 194 | ADMIN_FIRSTNAME: Admin 195 | ADMIN_LASTNAME: Inistrator 196 | ADMIN_PASSWORD: password123 197 | ADMIN_FRONTNAME: admin 198 | ADMIN_EMAIL: admin@example.com 199 | ``` 200 | 201 | ### Change the MySQL Root User Password 202 | 203 | I chose a very weak passwords for the MySQL root-user. You can change it by modifying the respective environment variables for the **mysql-container** ... and **installer** because otherwise the installation will fail: 204 | 205 | ```yaml 206 | installer: 207 | environment: 208 | MYSQL_PASSWORD: 209 | mysql: 210 | environment: 211 | MYSQL_ROOT_PASSWORD: 212 | ``` 213 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "andreaskoch/dockerized-magento", 3 | "description": "Dockerized Magento Community Edition 1.9.x", 4 | "license": "BSD-3-Clause", 5 | "homepage": "https://github.com/andreaskoch/dockerized-magento", 6 | "require": { 7 | "avstudnitz/scopehint": "^0.6", 8 | "tim-reynolds/magento-qconfig": "1.0", 9 | "aoepeople/aoe_scheduler": "^1", 10 | "aschroder/smtp_pro": "^2", 11 | "gordonlesti/lesti_fpc": "^1", 12 | "jeroenvermeulen/solarium": "v1.6.9-beta", 13 | "aydin-hassan/magento-core-composer-installer": "*", 14 | "colinmollenhour/modman": "*", 15 | "theseer/autoload": "*", 16 | "magento/core": "^1.9" 17 | }, 18 | "require-dev": { 19 | "aoepeople/aoe_profiler": "v0.3.0", 20 | "aoepeople/aoe_templatehints": "^0.4" 21 | }, 22 | "repositories": [ 23 | { 24 | "type": "composer", 25 | "url": "https://packages.firegento.com" 26 | } 27 | ], 28 | "extra": { 29 | "magento-root-dir": "web", 30 | "auto-append-gitignore": true 31 | }, 32 | "config": { 33 | "discard-changes": true 34 | }, 35 | "minimum-stability": "dev", 36 | "prefer-stable": true, 37 | "scripts": { 38 | "post-install-cmd": [ 39 | ], 40 | "post-update-cmd": [ 41 | ] 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /config/installer/bin/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | ##################################### 6 | # Update the Magento Installation 7 | # Arguments: 8 | # None 9 | # Returns: 10 | # None 11 | ##################################### 12 | function updateMagento() { 13 | cd /var/www/html 14 | composer update 15 | } 16 | 17 | ##################################### 18 | # Print URLs and Logon Information 19 | # Arguments: 20 | # None 21 | # Returns: 22 | # None 23 | ##################################### 24 | function printLogonInformation() { 25 | baseUrl="http://$DOMAIN" 26 | frontendUrl="$baseUrl/" 27 | backendUrl="$baseUrl/admin" 28 | 29 | echo "" 30 | echo "phpMyAdmin: $baseUrl:8080" 31 | echo " - Username: ${MYSQL_USER}" 32 | echo " - Password: ${MYSQL_PASSWORD}" 33 | echo "" 34 | echo "Backend: $backendUrl" 35 | echo " - Username: ${ADMIN_USERNAME}" 36 | echo " - Password: ${ADMIN_PASSWORD}" 37 | echo "" 38 | echo "Frontend: $frontendUrl" 39 | } 40 | 41 | 42 | ##################################### 43 | # Fix the filesystem permissions for the magento root. 44 | # Arguments: 45 | # None 46 | # Returns: 47 | # None 48 | ##################################### 49 | function fixFilesystemPermissions() { 50 | chmod -R go+rw $MAGENTO_ROOT 51 | } 52 | 53 | ##################################### 54 | # A never-ending while loop (which keeps the installer container alive) 55 | # Arguments: 56 | # None 57 | # Returns: 58 | # None 59 | ##################################### 60 | function runForever() { 61 | while : 62 | do 63 | sleep 1 64 | done 65 | } 66 | 67 | # Fix the www-folder permissions 68 | chgrp -R 33 /var/www/html 69 | 70 | # Check if the MAGENTO_ROOT direcotry has been specified 71 | if [ -z "$MAGENTO_ROOT" ] 72 | then 73 | echo "Please specify the root directory of Magento via the environment variable: MAGENTO_ROOT" 74 | exit 1 75 | fi 76 | 77 | # Check if the specified MAGENTO_ROOT direcotry exists 78 | if [ ! -d "$MAGENTO_ROOT" ] 79 | then 80 | mkdir -p $MAGENTO_ROOT 81 | fi 82 | 83 | # Check if there is alreay an index.php. If yes, abort the installation process. 84 | if [ -e "$MAGENTO_ROOT/index.php" ] 85 | then 86 | echo "Magento is already installed." 87 | echo "Updating Magento" 88 | updateMagento 89 | 90 | echo "Fixing filesystem permissions" 91 | fixFilesystemPermissions 92 | 93 | echo "Update fininished" 94 | printLogonInformation 95 | 96 | runForever 97 | exit 0 98 | fi 99 | 100 | echo "Preparing the Magerun Configuration" 101 | substitute-env-vars.sh /etc /etc/n98-magerun.yaml.tmpl 102 | 103 | echo "Installing Magento" 104 | updateMagento 105 | 106 | echo "Preparing the Magento Configuration" 107 | substitute-env-vars.sh /etc /etc/local.xml.tmpl 108 | substitute-env-vars.sh /etc /etc/fpc.xml.tmpl 109 | 110 | echo "Overriding Magento Configuration" 111 | cp -v /etc/local.xml /var/www/html/web/app/etc/local.xml 112 | cp -v /etc/fpc.xml /var/www/html/web/app/etc/fpc.xml 113 | chgrp -R 33 $MAGENTO_ROOT/app/etc 114 | 115 | echo "Installing Sample Data: Media" 116 | curl -s -L https://raw.githubusercontent.com/Vinai/compressed-magento-sample-data/1.9.1.0/compressed-no-mp3-magento-sample-data-1.9.1.0.tgz | tar xz -C /tmp 117 | cp -av /tmp/magento-sample-data-*/* $MAGENTO_ROOT 118 | rm -rf /tmp/magento-sample-data-* 119 | chgrp -R 33 $MAGENTO_ROOT 120 | 121 | echo "Installing Sample Data: Database" 122 | magerun --skip-root-check --root-dir="$MAGENTO_ROOT" db:create 123 | databaseFilePath="$MAGENTO_ROOT/*.sql" 124 | magerun --skip-root-check --root-dir="$MAGENTO_ROOT" db:import $databaseFilePath 125 | rm $databaseFilePath 126 | 127 | echo "Installing Sample Data: Reindex" 128 | magerun --skip-root-check --root-dir="$MAGENTO_ROOT" cache:clean 129 | magerun --skip-root-check --root-dir="$MAGENTO_ROOT" index:reindex:all 130 | 131 | echo "Installing Sample Data: Admin User" 132 | magerun --skip-root-check --root-dir="$MAGENTO_ROOT" \ 133 | admin:user:create \ 134 | "${ADMIN_USERNAME}" \ 135 | "${ADMIN_EMAIL}" \ 136 | "${ADMIN_PASSWORD}" \ 137 | "${ADMIN_FIRSTNAME}" \ 138 | "${ADMIN_LASTNAME}" \ 139 | "Administrators" 140 | 141 | echo "Enable Fullpage Cache" 142 | magerun --skip-root-check --root-dir="$MAGENTO_ROOT" cache:enable fpc 143 | 144 | echo "Fixing filesystem permissions" 145 | fixFilesystemPermissions 146 | 147 | echo "Installation fininished" 148 | printLogonInformation 149 | 150 | runForever 151 | exit 0 152 | -------------------------------------------------------------------------------- /config/installer/bin/substitute-env-vars.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | output_dir=$1 6 | shift 7 | files=$@ 8 | 9 | function fill_in() { 10 | perl -p -e 's/\$\{([^}]+)\}/defined $ENV{$1} ? $ENV{$1} : "\${$1}"/eg' "${1}" 11 | } 12 | 13 | function output_filename { 14 | local destname=$(basename "${1}" '.tmpl') 15 | echo "${output_dir}/${destname}" 16 | } 17 | 18 | for file in $files; do 19 | fill_in "${file}" > $(output_filename "${file}") 20 | done -------------------------------------------------------------------------------- /config/installer/magento/fpc.xml.tmpl: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | 18 | 86400 19 | Cm_Cache_Backend_Redis 20 | 21 | redisfullpagecache 22 | 6379 23 | cache-fpc 24 | 0 25 | 26 | 1 27 | 1 28 | 86400 29 | 10 30 | 1 31 | 1 32 | gzip 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /config/installer/magento/local.xml.tmpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | false 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 1 26 | 27 | 28 | 29 | db 30 | 31 | redissession 32 | 6379 33 | 34 | 2.5 35 | 36 | 0 37 | 2048 38 | gzip 39 | 1 40 | 6 41 | 5 42 | 30 43 | 7200 44 | 0 45 | 46 | 47 | Mage_Cache_Backend_Redis 48 | 49 | rediscache 50 | 6379 51 | 52 | 0 53 | 54 | 0 55 | 1 56 | 10 57 | 0 58 | 1 59 | 1 60 | 20480 61 | gzip 62 | 0 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | http://${DOMAIN}/ 79 | http://${DOMAIN}/ 80 | http://${DOMAIN}/skin/ 81 | http://${DOMAIN}/media/ 82 | http://${DOMAIN}/js/ 83 | 84 | 85 | 0 86 | 1 87 | https://${DOMAIN}/ 88 | https://${DOMAIN}/ 89 | https://${DOMAIN}/skin/ 90 | https://${DOMAIN}/media/ 91 | https://${DOMAIN}/js/ 92 | 93 | 94 | ${DOMAIN} 95 | 96 | 97 | 98 | 99 | EUR 100 | EUR 101 | 102 | 103 | 104 | 105 | 1 106 | 107 | 108 | solr 109 | 8983 110 | /solr 111 | collection1 112 | 113 | 114 | 115 | 118 | 119 | 1 120 | 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /config/installer/magerun/n98-magerun.yaml.tmpl: -------------------------------------------------------------------------------- 1 | commands: 2 | N98\Magento\Command\Installer\InstallCommand: 3 | installation: 4 | 5 | defaults: 6 | currency: EUR 7 | locale: en_GB 8 | timezone: Europe/London 9 | use_secure: no 10 | use_rewrites: yes 11 | session_save: files 12 | admin_username: ${ADMIN_USERNAME} 13 | admin_firstname: ${ADMIN_FIRSTNAME} 14 | admin_lastname: ${ADMIN_LASTNAME} 15 | admin_password: ${ADMIN_PASSWORD} 16 | admin_frontname: ${ADMIN_FRONTNAME} 17 | admin_email: ${ADMIN_EMAIL} 18 | encryption_key: ${ENCRYPTIONKEY} 19 | -------------------------------------------------------------------------------- /config/installer/php/php.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | 3 | ;;;;;;;;;;;;;;;;;;; 4 | ; Resource Limits ; 5 | ;;;;;;;;;;;;;;;;;;; 6 | 7 | max_execution_time = 1800 8 | max_input_time = 60 9 | memory_limit = 2G 10 | upload_max_filesize = 32M 11 | 12 | date.timezone = "UTC" -------------------------------------------------------------------------------- /config/nginx/custom-locations/custom.location: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andreaskoch/dockerized-magento/409b84edfff2557838bb595cd71ffb797e263cfa/config/nginx/custom-locations/custom.location -------------------------------------------------------------------------------- /config/nginx/includes/api: -------------------------------------------------------------------------------- 1 | # Disable Basic Auth for the API 2 | location ~ ^/index\.php/api/ { 3 | rewrite .* /index.php break; 4 | 5 | auth_basic off; 6 | expires off; 7 | 8 | include /etc/nginx/includes/magento-fastcgi; 9 | include /etc/nginx/custom-includes/*-fastcgi; 10 | } -------------------------------------------------------------------------------- /config/nginx/includes/fastcgi: -------------------------------------------------------------------------------- 1 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 2 | 3 | fastcgi_pass php:9000; 4 | fastcgi_index index.php; 5 | 6 | include fastcgi_params; 7 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 8 | 9 | fastcgi_param MAGENTO_ROOT /var/www/html/web; 10 | fastcgi_param REMOTE_ADDR $remote_addr; 11 | 12 | fastcgi_buffer_size 1024k; 13 | fastcgi_buffers 500 512k; 14 | fastcgi_connect_timeout 1200; 15 | fastcgi_send_timeout 1200; 16 | fastcgi_read_timeout 1200; 17 | -------------------------------------------------------------------------------- /config/nginx/includes/gzip: -------------------------------------------------------------------------------- 1 | gzip on; 2 | gzip_min_length 1000; 3 | gzip_proxied any; 4 | gzip_types text/plain 5 | application/xml 6 | text/css 7 | text/js 8 | application/javascript 9 | application/x-javascript; -------------------------------------------------------------------------------- /config/nginx/includes/minify: -------------------------------------------------------------------------------- 1 | rewrite ^/minify/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last; 2 | rewrite ^/skin/m/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last; 3 | 4 | location /lib/minify/ { 5 | allow all; 6 | } -------------------------------------------------------------------------------- /config/nginx/nginx.conf: -------------------------------------------------------------------------------- 1 | user nginx; 2 | worker_processes 4; 3 | pid /var/run/nginx.pid; 4 | 5 | events { 6 | worker_connections 1024; 7 | } 8 | 9 | http { 10 | include /etc/nginx/mime.types; 11 | default_type application/octet-stream; 12 | 13 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 14 | '$status $body_bytes_sent "$http_referer" ' 15 | '"$http_user_agent" "$http_x_forwarded_for"'; 16 | 17 | access_log /var/log/nginx/access.log main; 18 | error_log /var/log/nginx/error.log warn; 19 | 20 | sendfile on; 21 | keepalive_timeout 65; 22 | 23 | include /etc/nginx/conf.d/*; 24 | } 25 | -------------------------------------------------------------------------------- /config/nginx/sites-enabled/default.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80 default_server; 3 | listen 443 default_server ssl; 4 | 5 | ssl_certificate /etc/nginx/ssl/cert.pem; 6 | ssl_certificate_key /etc/nginx/ssl/cert.key; 7 | 8 | client_max_body_size 10M; 9 | 10 | root /var/www/html/web; 11 | index index.php; 12 | 13 | # Handle images directly 14 | location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf)$ { 15 | root /var/www/html/web; 16 | } 17 | 18 | location / { 19 | index index.html index.php; 20 | try_files $uri $uri/ @handler; 21 | expires 30d; 22 | } 23 | 24 | location ^~ /app/ { deny all; } 25 | location ^~ /includes/ { deny all; } 26 | location ^~ /lib/ { deny all; } 27 | location ^~ /media/downloadable/ { deny all; } 28 | location ^~ /pkginfo/ { deny all; } 29 | location ^~ /report/config.xml { deny all; } 30 | location ^~ /var/ { deny all; } 31 | location /var/export/ { deny all; } 32 | 33 | # Custom Locations 34 | include /etc/nginx/custom-locations/*.location; 35 | 36 | location /api { 37 | rewrite ^/api/rest /api.php?type=rest last; 38 | rewrite ^/api/v2_soap /api.php?type=v2_soap last; 39 | rewrite ^/api/soap /api.php?type=soap last; 40 | } 41 | 42 | location ~ ^/cron\.(sh|php) { 43 | return 404; 44 | } 45 | 46 | location /. { 47 | return 404; 48 | } 49 | 50 | location @handler { 51 | rewrite / /index.php; 52 | } 53 | 54 | location ~ \.php/ { 55 | rewrite ^(.*\.php)/ $1 last; 56 | } 57 | 58 | 59 | # All PHP Requests 60 | location ~ \.php$ { 61 | 62 | ## Catch 404s that try_files miss 63 | if (!-e $request_filename) { 64 | rewrite / /index.php last; 65 | } 66 | 67 | include /etc/nginx/includes/fastcgi; 68 | } 69 | 70 | include /etc/nginx/includes/minify; 71 | include /etc/nginx/includes/gzip; 72 | } 73 | -------------------------------------------------------------------------------- /config/ssl/cert.csr: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIICoTCCAYkCAQAwXDELMAkGA1UEBhMCREUxEzARBgNVBAgTClNvbWUtU3RhdGUx 3 | GzAZBgNVBAoTEmRvY2tlcml6ZWQtbWFnZW50bzEbMBkGA1UEAxMSZG9ja2VyaXpl 4 | ZC1tYWdlbnRvMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzH4Ev70Y 5 | b4d6MJnmtDXysKMDvDq19vR5jAMtnNzrbbKnbBss0BtZfTA35OoKHJCkY2lFfVdF 6 | OW1Mw41srEtAcokAnEuO4XJ8rCrRdzCfLrvfIFDWlkg9RkdGtVm55L2UEOIY2j7Y 7 | GhcqSPXGEjfhiVom5YL5DVa5JCT0GyKj3aAN6eu9Bc9cuFcngJNgBzJAl/XKDktT 8 | VnsJOuG7hDPzD9ICcJos8Mm7cuocqK9l5Mw5EaCK+uqGBSZtkqf0v32iqXSjEQS0 9 | WyxHdC8WIGTH6DKZf1F+QgVZUv0MNCQlSvNzmKK7BVLhbpOxoRiwsT5Mps32Q409 10 | nccBzmwnByMTGwIDAQABoAAwDQYJKoZIhvcNAQEFBQADggEBACChDtUrxlfFNRbw 11 | vm6DwHSpBAZgee+5IoqXko76DpWTQzXTxxmZAY6IfvkJHPHlxkdYhojuEmPGfgWs 12 | EzQVrj/Ld8YeBleROtFSL6911dc2n41sFCTZUhZ2aP/RtzO/IX/fBhs/zAtGvKn/ 13 | Z7gke5cD5D6/xhqIv7wngkxI4w54oS7y83ei1ZRpKqVhf6VM9vcmTPWXxPvYo2Bx 14 | HyvLLz8D7AEQ7kXKkv+YRFK1l11ca1GuGSf9I0jSJ3n43Gxt6Sk1MwrP0PyQBJh8 15 | +hbgr4neVAtFAXghC7Ky29qIrd8RxBWra1892gCzh4ie9nfHgQYgR4qhz5ebfS56 16 | PubY9ck= 17 | -----END CERTIFICATE REQUEST----- 18 | -------------------------------------------------------------------------------- /config/ssl/cert.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEpQIBAAKCAQEAzH4Ev70Yb4d6MJnmtDXysKMDvDq19vR5jAMtnNzrbbKnbBss 3 | 0BtZfTA35OoKHJCkY2lFfVdFOW1Mw41srEtAcokAnEuO4XJ8rCrRdzCfLrvfIFDW 4 | lkg9RkdGtVm55L2UEOIY2j7YGhcqSPXGEjfhiVom5YL5DVa5JCT0GyKj3aAN6eu9 5 | Bc9cuFcngJNgBzJAl/XKDktTVnsJOuG7hDPzD9ICcJos8Mm7cuocqK9l5Mw5EaCK 6 | +uqGBSZtkqf0v32iqXSjEQS0WyxHdC8WIGTH6DKZf1F+QgVZUv0MNCQlSvNzmKK7 7 | BVLhbpOxoRiwsT5Mps32Q409nccBzmwnByMTGwIDAQABAoIBAQDDYlzzPp/MYGuV 8 | aFcQNMOPlhIJlScrsGc6Kgc467ReeeaR2l008gzNGnctV5kVtfX7rifhHLNdrVs9 9 | NTFyZexMAy78Jw17x0Hr1nWRJnnR01vbqqF9scQqFAwxVmvRbHm+r+kDDiy4sQ2L 10 | 7Ji164KpE+Q6Qqvn3MbFDDHYg36CT6eAigTzjW5jLDSbZ5SoZy1pYR5rSkU7VbDs 11 | TzSqL5JaijuFJ2NaoqBZqKYbkb8BLEMuWg0copxEBZ1DiIv+921ng6Vd9GR6yqIc 12 | yOhR4qV2drqc8LMHpcK0nbt2a1Q/BX+fAM64Mh8TC0P6UriBluKQ6eb6iFm7Th58 13 | PrrxzqfhAoGBAPALuGnRlPDc8qBzOUxczTjL5Dp1CWfN6yN1AnIbhn5b4MSzY2JO 14 | JPBSmf+a1d2YPWO2KblWuFuE/ViOmB9S6eQeQmGqFOzp5UAfqwk2SiYhUqtV41pM 15 | Drz4Qxgtj+gqXr6DCrC7XK5yBT5NacugsyItExNejUXBazJVhVoQ+j4ZAoGBANoV 16 | XqWC0/Pv4489DZv+Vf6YoscK0adZx7v3VwMeEtnpdJ825NgNj39m45IRaDo5uN4g 17 | 0zEVZs+sO45NY9mMDysCmj/kHNSFKIa/dgobTn+ggm9itbn1WuL9fLwnlaily2O7 18 | 0lkwSsOgC6EmaB11BQuNdUmwQW/WPkDF/k/ChJlTAoGBANKHFPgJzfzpawn5xHkK 19 | sxprCAGU/+jAmseAKeL17SEJZ7pcMn/XVWJIr7OTkppEmSLIcxOP0STDIIb4mMZw 20 | K53cRA/v4WZfRKbWn2T27lU+yIhoTXu2VP67Je0gmKPf9TRVLZ0O1hxQ9/RKZM0o 21 | ZbNFoQNN280f8+ozQz9YwICRAoGARX23uf+1MC7JkTQAKSvjFQxoGgqdgbj/Bysq 22 | Y8jqctuMGMuyIhI4Hn2XmEzJrHwGJ2nIQgSyzQvxskeAwKp7jtX2dtNmSGXh4wYR 23 | Q+ktm0d3KK0IgSfofRoO7Bmk+6dQ5wfLYDYeLLXL3t7RIEnQgLzjmcZ7I3rePV+Z 24 | yKqP/BcCgYEAlZWUGCN2FKHJ4kElkkB766d0tuWOU0ohZf/giQHZFa+hcLS2Hx9C 25 | CSP6xOvW1FfT8AGUlbaBveWmMOGjTa7F5XykmMmTl2aMpDOQT9AeCgGqVFFFfija 26 | 5y/kZr4yTUV4HRYsw2yNX0eI9hy7+39ggMuf812pLcY29pMlBjZp3rk= 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /config/ssl/cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDNDCCAhwCCQCD5eq3fRaKODANBgkqhkiG9w0BAQUFADBcMQswCQYDVQQGEwJE 3 | RTETMBEGA1UECBMKU29tZS1TdGF0ZTEbMBkGA1UEChMSZG9ja2VyaXplZC1tYWdl 4 | bnRvMRswGQYDVQQDExJkb2NrZXJpemVkLW1hZ2VudG8wHhcNMTUxMTE0MTQyMjQ0 5 | WhcNMjQwMTMxMTQyMjQ0WjBcMQswCQYDVQQGEwJERTETMBEGA1UECBMKU29tZS1T 6 | dGF0ZTEbMBkGA1UEChMSZG9ja2VyaXplZC1tYWdlbnRvMRswGQYDVQQDExJkb2Nr 7 | ZXJpemVkLW1hZ2VudG8wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDM 8 | fgS/vRhvh3owmea0NfKwowO8OrX29HmMAy2c3OttsqdsGyzQG1l9MDfk6gockKRj 9 | aUV9V0U5bUzDjWysS0ByiQCcS47hcnysKtF3MJ8uu98gUNaWSD1GR0a1WbnkvZQQ 10 | 4hjaPtgaFypI9cYSN+GJWiblgvkNVrkkJPQbIqPdoA3p670Fz1y4VyeAk2AHMkCX 11 | 9coOS1NWewk64buEM/MP0gJwmizwybty6hyor2XkzDkRoIr66oYFJm2Sp/S/faKp 12 | dKMRBLRbLEd0LxYgZMfoMpl/UX5CBVlS/Qw0JCVK83OYorsFUuFuk7GhGLCxPkym 13 | zfZDjT2dxwHObCcHIxMbAgMBAAEwDQYJKoZIhvcNAQEFBQADggEBABWSvq4Xrzit 14 | Lz1qp7q4arFHmzvUYaG2+9dAafrUt6XfMaaZYJ9oUA5mBC+DmBhjZEgUwqsU9um6 15 | mrmf8sJlhpH7idniYiP1HNa63wa5guVyYnUOLPre1KrT514aZOTFYkB4lMoNil1G 16 | 33K2oCF7/lJt/hxEToJIRZZs00yQ60oMYqEAqya5J6A0F3OOljBOlScWYO2PldiM 17 | zLZov2nnNaBsplloqA0f84ZoXH7twKsG47UH2xZO+4NS1lBxyLevcM2kkwVwc3Ef 18 | 7TUsa640F0mlvk4vQXubWKvo5gxmQb8pUFhZxMNF68i3+hjvOZj+WuEzi9tt1lA/ 19 | 49R8XjgeKvw= 20 | -----END CERTIFICATE----- 21 | -------------------------------------------------------------------------------- /data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | installer: 2 | image: andreaskoch/dockerized-magento-installer 3 | environment: 4 | DOMAIN: dockerized-magento.local 5 | MAGENTO_ROOT: /var/www/html/web 6 | MYSQL_HOST: mysql 7 | MYSQL_DATABASE: magento 8 | MYSQL_USER: root 9 | MYSQL_PASSWORD: pw 10 | ADMIN_USERNAME: admin 11 | ADMIN_FIRSTNAME: Admin 12 | ADMIN_LASTNAME: Inistrator 13 | ADMIN_PASSWORD: password123 14 | ADMIN_FRONTNAME: admin 15 | ADMIN_EMAIL: admin@example.com 16 | ENCRYPTIONKEY: 731aea833710535779fe8c7c49bc6c4d 17 | volumes_from: 18 | - nginx 19 | volumes: 20 | - ./config/installer/php/php.ini:/usr/local/etc/php/php.ini 21 | - ./config/installer/magerun/n98-magerun.yaml.tmpl:/etc/n98-magerun.yaml.tmpl 22 | - ./config/installer/magento/local.xml.tmpl:/etc/local.xml.tmpl 23 | - ./config/installer/magento/fpc.xml.tmpl:/etc/fpc.xml.tmpl 24 | - ./config/installer/bin/substitute-env-vars.sh:/bin/substitute-env-vars.sh 25 | - ./config/installer/bin/install.sh:/bin/install.sh 26 | links: 27 | - "cache:rediscache" 28 | - "sessions:redissession" 29 | - "fullpagecache:redisfullpagecache" 30 | - "solr:solr" 31 | - "mysql:mysql" 32 | entrypoint: /bin/install.sh 33 | 34 | nginx: 35 | image: nginx:latest 36 | ports: 37 | - "80:80" 38 | - "443:443" 39 | links: 40 | - "php" 41 | volumes: 42 | - ./logs/nginx:/var/log/nginx 43 | - ./config/ssl/cert.pem:/etc/nginx/ssl/cert.pem 44 | - ./config/ssl/cert.key:/etc/nginx/ssl/cert.key 45 | - ./config/nginx/nginx.conf:/etc/nginx/nginx.conf 46 | - ./config/nginx/sites-enabled/default.conf:/etc/nginx/conf.d/default.conf 47 | - ./config/nginx/includes:/etc/nginx/includes 48 | - ./config/nginx/custom-locations:/etc/nginx/custom-locations 49 | volumes_from: 50 | - php 51 | php: 52 | image: andreaskoch/dockerized-magento-php 53 | links: 54 | - "cache:rediscache" 55 | - "sessions:redissession" 56 | - "fullpagecache:redisfullpagecache" 57 | - "solr:solr" 58 | - "mysql:mysql" 59 | volumes: 60 | - .:/var/www/html 61 | mysql: 62 | image: mysql:5.5 63 | ports: 64 | - "3306:3306" 65 | environment: 66 | MYSQL_ROOT_PASSWORD: pw 67 | volumes: 68 | - ./data/mysql:/var/lib/mysql 69 | solr: 70 | image: andreaskoch/dockerized-magento-solr 71 | cache: 72 | image: redis:latest 73 | fullpagecache: 74 | image: redis:latest 75 | sessions: 76 | image: redis:latest 77 | phpmyadmin: 78 | image: phpmyadmin/phpmyadmin 79 | ports: 80 | - "8080:80" 81 | links: 82 | - "mysql:mysql" 83 | environment: 84 | PMA_HOST: "mysql" 85 | PMA_PORT: 3306 86 | -------------------------------------------------------------------------------- /docker-images/installer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:5.6 2 | 3 | # Configure PHP 4 | RUN buildDeps=" \ 5 | libpng12-dev \ 6 | libjpeg-dev \ 7 | libmcrypt-dev \ 8 | libxml2-dev \ 9 | freetype* \ 10 | "; \ 11 | set -x \ 12 | && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \ 13 | && docker-php-ext-configure \ 14 | gd --with-png-dir=/usr --with-jpeg-dir=/usr --with-freetype-dir \ 15 | && docker-php-ext-install \ 16 | gd \ 17 | mbstring \ 18 | mysqli \ 19 | mcrypt \ 20 | mysql \ 21 | pdo_mysql \ 22 | zip \ 23 | && apt-get purge -y --auto-remove 24 | 25 | # Install Tools 26 | RUN apt-get update && \ 27 | apt-get install -y \ 28 | vim \ 29 | telnet \ 30 | netcat \ 31 | git-core \ 32 | zip && \ 33 | apt-get purge -y --auto-remove 34 | 35 | # Install magerun 36 | RUN curl -o magerun https://raw.githubusercontent.com/netz98/n98-magerun/master/n98-magerun.phar && \ 37 | chmod +x ./magerun && \ 38 | ./magerun selfupdate && \ 39 | cp ./magerun /usr/local/bin/ && \ 40 | rm ./magerun && \ 41 | apt-get update && \ 42 | apt-get install -qy mysql-client && \ 43 | apt-get purge -y --auto-remove 44 | 45 | # Install composer 46 | RUN curl -sS https://getcomposer.org/installer | php -- --filename=composer --install-dir=bin 47 | -------------------------------------------------------------------------------- /docker-images/nginx/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:latest 2 | 3 | RUN rm -rf /etc/nginx/conf.d/* 4 | 5 | COPY bin/ /usr/sbin/ 6 | COPY sites-templates /etc/nginx/sites-templates 7 | COPY nginx.conf /etc/nginx/nginx.conf 8 | 9 | WORKDIR /etc/nginx 10 | 11 | EXPOSE 80 443 12 | 13 | ENTRYPOINT ["entrypoint.sh"] 14 | CMD ["nginx"] 15 | -------------------------------------------------------------------------------- /docker-images/nginx/bin/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | templates_dir="/etc/nginx/sites-templates" 6 | outdir="/etc/nginx/conf.d" 7 | 8 | function template_files() { 9 | find "${templates_dir}" \ 10 | -mindepth 1 \ 11 | -maxdepth 1 \ 12 | -name '*.tmpl' \ 13 | -print0 14 | } 15 | 16 | function non_template_files() { 17 | find "${templates_dir}" \ 18 | -mindepth 1 \ 19 | -maxdepth 1 \ 20 | -not \ 21 | -name '*.tmpl' \ 22 | -print0 23 | } 24 | 25 | #clean 26 | rm -rf "${outdir}" 27 | mkdir -p "${outdir}" 28 | 29 | template_files | xargs -0 substitute-env-vars.sh "${outdir}" 30 | non_template_files | xargs -0 -I{} ln -s {} "${outdir}" 31 | 32 | exec $@ -------------------------------------------------------------------------------- /docker-images/nginx/bin/substitute-env-vars.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | output_dir=$1 6 | shift 7 | files=$@ 8 | 9 | function fill_in() { 10 | perl -p -e 's/\$\{([^}]+)\}/defined $ENV{$1} ? $ENV{$1} : "\${$1}"/eg' "${1}" 11 | } 12 | 13 | function output_filename { 14 | local destname=$(basename "${1}" '.tmpl') 15 | echo "${output_dir}/${destname}" 16 | } 17 | 18 | for file in $files; do 19 | fill_in "${file}" > $(output_filename "${file}") 20 | done -------------------------------------------------------------------------------- /docker-images/nginx/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 | error_log /var/log/nginx/error.log warn; 21 | 22 | sendfile on; 23 | #tcp_nopush on; 24 | 25 | keepalive_timeout 65; 26 | 27 | include /etc/nginx/conf.d/*.conf; 28 | } 29 | 30 | daemon off; 31 | -------------------------------------------------------------------------------- /docker-images/nginx/sites-templates/default.conf.tmpl: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80 default_server; 3 | listen 443 default_server ssl; 4 | 5 | ssl_certificate ${SSL_CERTIFICATE_PATH}; 6 | ssl_certificate_key ${SSL_CERTIFICATE_KEY_PATH}; 7 | 8 | client_max_body_size 10M; 9 | 10 | root ${MAGENTO_ROOT}; 11 | index index.php; 12 | 13 | # Serve images directly 14 | location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf)$ { 15 | root ${MAGENTO_ROOT}; 16 | } 17 | 18 | location / { 19 | index index.html index.php; 20 | try_files $uri $uri/ @handler; 21 | expires 30d; 22 | } 23 | 24 | location ^~ /app/ { deny all; } 25 | location ^~ /includes/ { deny all; } 26 | location ^~ /lib/ { deny all; } 27 | location ^~ /media/downloadable/ { deny all; } 28 | location ^~ /pkginfo/ { deny all; } 29 | location ^~ /report/config.xml { deny all; } 30 | location ^~ /var/ { deny all; } 31 | location ^~ /downloader/ { deny all; } 32 | location /var/export/ { deny all; } 33 | 34 | location /. { 35 | return 404; 36 | } 37 | 38 | location @handler { 39 | rewrite / /index.php; 40 | } 41 | 42 | location ~ \.php/ { 43 | rewrite ^(.*\.php)/ $1 last; 44 | } 45 | 46 | location ~ \.php$ { 47 | 48 | ## Catch 404s that try_files miss 49 | if (!-e $request_filename) { 50 | rewrite / /index.php last; 51 | } 52 | 53 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 54 | 55 | fastcgi_pass ${PHP_PORT_9000_TCP_ADDR}:${PHP_PORT_9000_TCP_PORT}; 56 | fastcgi_index index.php; 57 | 58 | include fastcgi_params; 59 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 60 | 61 | fastcgi_param MAGENTO_ROOT ${MAGENTO_ROOT}; 62 | fastcgi_param MAGE_IS_DEVELOPER_MODE ${MAGENTO_DEVELOPERMODE}; 63 | 64 | fastcgi_param REMOTE_ADDR $http_x_real_ip; 65 | fastcgi_buffer_size 1024k; 66 | fastcgi_buffers 500 512k; 67 | fastcgi_connect_timeout 1200; 68 | fastcgi_send_timeout 1200; 69 | fastcgi_read_timeout 1200; 70 | 71 | } 72 | 73 | rewrite ^/minify/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last; 74 | rewrite ^/skin/m/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last; 75 | 76 | location /lib/minify/ { 77 | allow all; 78 | } 79 | 80 | gzip on; 81 | gzip_min_length 1000; 82 | gzip_proxied any; 83 | } 84 | -------------------------------------------------------------------------------- /docker-images/php/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:5.6-fpm 2 | 3 | # Install 4 | RUN buildDeps=" \ 5 | libpng12-dev \ 6 | libjpeg-dev \ 7 | libmcrypt-dev \ 8 | libxml2-dev \ 9 | freetype* \ 10 | "; \ 11 | set -x \ 12 | && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \ 13 | && docker-php-ext-configure \ 14 | gd --with-png-dir=/usr --with-jpeg-dir=/usr --with-freetype-dir \ 15 | && docker-php-ext-install \ 16 | gd \ 17 | mbstring \ 18 | mysqli \ 19 | mcrypt \ 20 | mysql \ 21 | pdo_mysql \ 22 | soap \ 23 | zip \ 24 | && apt-get update -qy && apt-get install -qy git-core \ 25 | && cd /tmp/ && git clone https://github.com/derickr/xdebug.git \ 26 | && cd xdebug && phpize && ./configure --enable-xdebug && make \ 27 | && mkdir /usr/lib/php5/ && cp modules/xdebug.so /usr/lib/php5/xdebug.so \ 28 | && touch /usr/local/etc/php/ext-xdebug.ini \ 29 | && rm -r /tmp/xdebug && apt-get purge -y git-core \ 30 | && apt-get purge -y --auto-remove 31 | 32 | # Configure 33 | COPY php.ini /usr/local/etc/php/php.ini 34 | COPY php-fpm.conf /usr/local/etc/ 35 | COPY ext-xdebug.ini /usr/local/etc/php/conf.d/ext-xdebug.ini 36 | 37 | # Make sure the volume mount point is empty 38 | RUN rm -rf /var/www/html/* 39 | 40 | # Install magerun 41 | RUN curl -o magerun https://raw.githubusercontent.com/netz98/n98-magerun/master/n98-magerun.phar && \ 42 | chmod +x ./magerun && \ 43 | cp ./magerun /usr/local/bin/ && \ 44 | rm ./magerun && \ 45 | apt-get update && \ 46 | apt-get install -qy mysql-client 47 | -------------------------------------------------------------------------------- /docker-images/php/ext-xdebug.ini: -------------------------------------------------------------------------------- 1 | zend_extension="/usr/lib/php5/xdebug.so" 2 | xdebug.remote_enable=1 3 | xdebug.remote_port=9000 4 | xdebug.overload_var_dump=1 5 | xdebug.default_enable=1 6 | xdebug.remote_connect_back=1 7 | -------------------------------------------------------------------------------- /docker-images/php/php-fpm.conf: -------------------------------------------------------------------------------- 1 | ; This file was initially adapated from the output of: (on PHP 5.6) 2 | ; grep -vE '^;|^ *$' /usr/local/etc/php-fpm.conf.default 3 | 4 | [global] 5 | 6 | error_log = /proc/self/fd/2 7 | log_level = warning 8 | daemonize = no 9 | 10 | [www] 11 | 12 | ; if we send this to /proc/self/fd/1, it never appears 13 | access.log = /proc/self/fd/2 14 | 15 | user = www-data 16 | group = www-data 17 | 18 | listen = [::]:9000 19 | 20 | pm = dynamic 21 | pm.max_children = 5 22 | pm.start_servers = 2 23 | pm.min_spare_servers = 1 24 | pm.max_spare_servers = 3 25 | -------------------------------------------------------------------------------- /docker-images/php/php.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | 3 | ;;;;;;;;;;;;;;;;;;; 4 | ; Resource Limits ; 5 | ;;;;;;;;;;;;;;;;;;; 6 | 7 | max_execution_time = 1800 8 | max_input_time = 60 9 | memory_limit = 512M 10 | upload_max_filesize = 32M 11 | 12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 13 | ; Error handling and logging ; 14 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 15 | 16 | error_reporting = E_ALL & ~E_NOTICE | E_DEPRECATED 17 | display_errors = Off 18 | display_startup_errors = Off 19 | log_errors = On 20 | log_errors_max_len = 1024 21 | ignore_repeated_errors = Off 22 | ignore_repeated_source = Off 23 | report_memleaks = On 24 | track_errors = Off 25 | html_errors = On 26 | 27 | date.timezone = "UTC" 28 | -------------------------------------------------------------------------------- /docker-images/solr/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:latest 2 | 3 | # Install Solr 4 | RUN apt-get update -qy && \ 5 | apt-get install -qy wget openjdk-7-jre && \ 6 | wget http://archive.apache.org/dist/lucene/solr/4.9.1/solr-4.9.1.tgz && \ 7 | tar -xvf solr-4.9.1.tgz -C /usr/local && \ 8 | rm solr-4.9.1.tgz && \ 9 | apt-get -qy purge wget && \ 10 | apt-get clean && \ 11 | rm -rf /tmp/* 12 | 13 | # Configure Solr 14 | ENV SOLRPATH /usr/local/solr-4.9.1/example 15 | COPY conf/* $SOLRPATH/solr/collection1/conf/ 16 | 17 | WORKDIR $SOLRPATH 18 | 19 | EXPOSE 8983 20 | CMD ["/usr/bin/java", "-Xmx1024m", "-DSTOP.PORT=55101", "-DSTOP.KEY=stop-jetty-solr", "-jar", "start.jar"] 21 | -------------------------------------------------------------------------------- /docker-images/solr/conf/schema.xml: -------------------------------------------------------------------------------- 1 | 2 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | id 57 | 58 | text 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /docker-images/solr/conf/solrconfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 24 | 25 | 26 | 27 | LUCENE_CURRENT 28 | 29 | ${solr.abortOnConfigurationError:true} 30 | 31 | ${solr.data.dir:} 32 | 33 | 34 | 35 | 36 | 37 | 38 | ${solr.lock.type:native} 39 | 40 | 41 | 42 | 43 | ${solr.ulog.dir:} 44 | 45 | 46 | 15000 47 | false 48 | 49 | 50 | 51 | 52 | 1024 53 | 57 | 61 | 65 | true 66 | 20 67 | 200 68 | false 69 | 2 70 | 71 | 72 | 73 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | text 83 | /select 84 | solrpingquery 85 | 86 | 87 | 88 | 89 | 90 | spellcheck 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | text_general 101 | 102 | text 103 | 2 104 | 0 105 | 3 106 | true 107 | 108 | 109 | 110 | 111 | text/plain; charset=UTF-8 112 | 113 | 114 | -------------------------------------------------------------------------------- /documentation/dockerized-magento-component-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andreaskoch/dockerized-magento/409b84edfff2557838bb595cd71ffb797e263cfa/documentation/dockerized-magento-component-diagram.png -------------------------------------------------------------------------------- /documentation/installation-and-first-start-animation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andreaskoch/dockerized-magento/409b84edfff2557838bb595cd71ffb797e263cfa/documentation/installation-and-first-start-animation.gif -------------------------------------------------------------------------------- /logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /magento: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # A control-script for managing the docker-infrastructure components for Magento 4 | 5 | # The first parameter is the action name 6 | action=$1 7 | 8 | # All other arguments are parameters 9 | if [ "$#" -gt "1" ]; then 10 | shift 11 | parameters=$@ 12 | fi 13 | 14 | # Paths 15 | SCRIPTNAME=`basename $0` 16 | SCRIPTPATH=$(readlink -f "$0" 2>/dev/null) 17 | if [ "$?" != 0 ]; then 18 | if [ ! -f "docker-compose.yml" ]; then 19 | >&2 echo " The $SCRIPTNAME-script will only work (on Mac OS) if you execute it from the project directory itself." 20 | exit 1 21 | fi 22 | SCRIPTPATH="$(pwd -P)/$SCRIPTNAME" 23 | fi 24 | PROJECTPATH=$(dirname "$SCRIPTPATH") 25 | 26 | # Switch into the project directory 27 | cd $PROJECTPATH 28 | 29 | # Mandatory Tools 30 | DOCKER=`which docker` 31 | if [ -z "$DOCKER" ]; 32 | then 33 | echo "'docker' was not found on your system." >&2 34 | exit 1 35 | fi 36 | 37 | DOCKERCOMPOSE=`which docker-compose` 38 | if [ -z "$DOCKERCOMPOSE" ]; 39 | then 40 | echo "'docker-compose' was not found on your system." >&2 41 | exit 1 42 | fi 43 | 44 | # Utils 45 | XARGS=`which xargs` 46 | GREP=`which grep` 47 | SED=`which sed` 48 | 49 | ######################################################################### 50 | # Get the full container name for the given container type (e.g. "php") 51 | # Arguments: 52 | # CONTAINER_TYPE 53 | # Returns: 54 | # The full name of the (first) container with the given type 55 | ######################################################################### 56 | getContainerNameByType() { 57 | # abort if no type is specified 58 | local CONTAINER_TYPE="$1" 59 | if [ -z "$CONTAINER_TYPE" ]; 60 | then 61 | echo "No container type specified. Please specifiy a container type (e.g. php, installer, mysql, nginx, ...)." >&2 62 | return 1 63 | fi 64 | 65 | # check if xargs is available 66 | if [ -z "$XARGS" ]; 67 | then 68 | echo "The tool 'xargs' was not found on your system." >&2 69 | return 1 70 | fi 71 | 72 | # check if grep is available 73 | if [ -z "$GREP" ]; 74 | then 75 | echo "The tool 'grep' was not found on your system." >&2 76 | return 1 77 | fi 78 | 79 | # check if sed is available 80 | if [ -z "$SED" ]; 81 | then 82 | echo "The tool 'sed' was not found on your system." >&2 83 | return 1 84 | fi 85 | 86 | local containerName=$($DOCKER ps -q | $XARGS $DOCKER inspect --format '{{.Name}}' | $GREP "$CONTAINER_TYPE" | $SED 's:/::' | $GREP "$CONTAINER_TYPE_1") 87 | echo $containerName 88 | return 0 89 | } 90 | 91 | executeMagerun() { 92 | local containerType="installer" 93 | local containerName=$(getContainerNameByType "$containerType") 94 | if [ -z "$containerName" ]; 95 | then 96 | echo "Cannot determine the name of the container." >&2 97 | return 1 98 | fi 99 | 100 | $DOCKER exec -ti $containerName magerun --skip-root-check --root-dir="/var/www/html/web" $@ 101 | return 0 102 | } 103 | 104 | executeComposer() { 105 | local containerType="installer" 106 | local containerName=$(getContainerNameByType $containerType) 107 | if [ -z "$containerName" ]; 108 | then 109 | echo "Cannot determine the name of the container." >&2 110 | return 1 111 | fi 112 | 113 | $DOCKER exec $containerName composer --working-dir="/var/www/html" $@ 114 | return 0 115 | } 116 | 117 | enterContainer() { 118 | local containerType="$1" 119 | if [ -z "$containerType" ]; 120 | then 121 | echo "No container type specified. Please specifiy a container type (e.g. php, installer, mysql, nginx, ...)." >&2 122 | return 1 123 | fi 124 | 125 | local containerName=$(getContainerNameByType $containerType) 126 | if [ -z "$containerName" ]; 127 | then 128 | echo "Cannot determine the name of the container." >&2 129 | return 1 130 | fi 131 | 132 | $DOCKER exec -ti $containerName bash 133 | return 0 134 | } 135 | 136 | start() { 137 | $DOCKERCOMPOSE up -d && $DOCKERCOMPOSE logs -f 138 | } 139 | 140 | stop() { 141 | $DOCKERCOMPOSE stop 142 | } 143 | 144 | restart() { 145 | $DOCKERCOMPOSE restart 146 | executeMagerun cache:clean 147 | } 148 | 149 | status() { 150 | $DOCKERCOMPOSE ps 151 | } 152 | 153 | stats() { 154 | # check if sed is available 155 | if [ -z "$SED" ]; 156 | then 157 | echo "Stats requires 'sed'. The tool was not found on your system." >&2 158 | return 1 159 | fi 160 | 161 | $DOCKER ps -q | $XARGS $DOCKER inspect --format '{{.Name}}' | $SED 's:/::' | $XARGS $DOCKER stats 162 | } 163 | 164 | magerun() { 165 | executeMagerun $parameters 166 | } 167 | 168 | composer() { 169 | executeComposer $parameters 170 | } 171 | 172 | enter() { 173 | enterContainer $parameters 174 | } 175 | 176 | destroy() { 177 | $DOCKERCOMPOSE stop 178 | $DOCKERCOMPOSE rm --force 179 | rm -rf $PROJECTPATH/web $PROJECTPATH/db $PROJECTPATH/vendor 180 | } 181 | 182 | case "$action" in 183 | start) 184 | start 185 | ;; 186 | 187 | stop) 188 | stop 189 | ;; 190 | 191 | restart) 192 | restart 193 | ;; 194 | 195 | status) 196 | status 197 | ;; 198 | 199 | stats) 200 | stats 201 | ;; 202 | 203 | magerun) 204 | magerun 205 | ;; 206 | 207 | composer) 208 | composer 209 | ;; 210 | 211 | enter) 212 | enter 213 | ;; 214 | 215 | destroy) 216 | destroy 217 | ;; 218 | 219 | *) 220 | echo "usage : $0 start|stop|restart|status|stats|magerun|composer|enter|destroy 221 | 222 | start Starts the docker containers (and triggers the 223 | installation if magento is not yet installed) 224 | stop Stops all docker containers 225 | restart Restarts all docker containers 226 | status Prints the status of all docker containers 227 | stats Displays live resource usage statistics of all containers 228 | magerun Executes magerun in the magento root directory 229 | composer Executes composer in the magento root directory 230 | enter Enters the bash of a given container type (e.g. php, mysql) 231 | destroy Stops all containers and removes all data 232 | " 233 | ;; 234 | esac 235 | 236 | exit 0 237 | --------------------------------------------------------------------------------