├── .gitignore ├── apache ├── vhost.conf ├── sites │ ├── .gitignore │ └── default.apache.conf └── Dockerfile ├── php-fpm ├── opencart.ini ├── Dockerfile └── opencart.pool.conf ├── .env-example ├── docker-compose.yml ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /logs 2 | /database 3 | 4 | .env 5 | -------------------------------------------------------------------------------- /apache/vhost.conf: -------------------------------------------------------------------------------- 1 | Include /etc/apache2/sites-available/*.conf 2 | -------------------------------------------------------------------------------- /apache/sites/.gitignore: -------------------------------------------------------------------------------- 1 | *.conf 2 | !default.conf 3 | !default.apache.conf 4 | -------------------------------------------------------------------------------- /php-fpm/opencart.ini: -------------------------------------------------------------------------------- 1 | date.timezone = UTC 2 | display_errors = Off 3 | log_errors = On 4 | -------------------------------------------------------------------------------- /.env-example: -------------------------------------------------------------------------------- 1 | # Build Variables 2 | 3 | ## MySQL 4 | MYSQL_DATABASE=opencart 5 | MYSQL_USER=opencart 6 | MYSQL_PASSWORD=password 7 | MYSQL_PORT=3306 8 | MYSQL_ROOT_PASSWORD=root 9 | -------------------------------------------------------------------------------- /apache/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM webdevops/apache:ubuntu-16.04 2 | 3 | ARG PHP_SOCKET=php-fpm:9000 4 | 5 | ENV WEB_PHP_SOCKET=$PHP_SOCKET 6 | 7 | ENV WEB_DOCUMENT_ROOT=/var/www/upload 8 | 9 | EXPOSE 80 443 10 | 11 | WORKDIR /var/www/ 12 | 13 | ADD vhost.conf /etc/apache2/sites-enabled/vhost.conf 14 | 15 | ENTRYPOINT ["/opt/docker/bin/entrypoint.sh"] 16 | 17 | CMD ["supervisord"] 18 | -------------------------------------------------------------------------------- /apache/sites/default.apache.conf: -------------------------------------------------------------------------------- 1 | 2 | ServerName opencart.test 3 | DocumentRoot /var/www/upload/ 4 | Options Indexes FollowSymLinks 5 | 6 | 7 | AllowOverride All 8 | 9 | Allow from all 10 | 11 | = 2.4> 12 | Require all granted 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /php-fpm/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.3-fpm 2 | 3 | ADD ./opencart.ini /usr/local/etc/php/conf.d 4 | ADD ./opencart.pool.conf /usr/local/etc/php-fpm.d/ 5 | 6 | RUN apt-get update && apt-get install -y \ 7 | libfreetype6-dev \ 8 | libjpeg62-turbo-dev \ 9 | libmcrypt-dev \ 10 | libpng-dev \ 11 | libzip-dev \ 12 | curl 13 | 14 | RUN apt-get install -y libmcrypt-dev 15 | RUN pecl install mcrypt-1.0.2 && docker-php-ext-enable mcrypt 16 | 17 | # Install extensions using the helper script provided by the base image 18 | RUN docker-php-ext-install \ 19 | zip \ 20 | pdo_mysql \ 21 | && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ 22 | && docker-php-ext-install -j$(nproc) gd \ 23 | && docker-php-ext-install mysqli 24 | 25 | RUN usermod -u 1000 www-data 26 | 27 | WORKDIR /var/www/opencart 28 | 29 | CMD ["php-fpm"] 30 | 31 | EXPOSE 9000 32 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | services: 4 | 5 | php-fpm: 6 | build: ./php-fpm 7 | volumes: 8 | - ../:/var/www 9 | expose: 10 | - "9000" 11 | environment: 12 | MYSQL_HOST: mysql 13 | MYSQL_USERNAME: ${MYSQL_USER} 14 | MYSQL_PASSWORD: ${MYSQL_PASSWORD} 15 | DB_NAME: ${MYSQL_DATABASE} 16 | MYSQL_PORT: 3306 17 | 18 | apache: 19 | build: ./apache 20 | volumes: 21 | - ./logs/apache:/var/log/apache2 22 | - ./apache/sites:/etc/apache2/sites-available 23 | - ../:/var/www 24 | ports: 25 | - "80:80" 26 | depends_on: 27 | - php-fpm 28 | 29 | mysql: 30 | image: mysql:5.7 31 | ports: 32 | - "3306:3306" 33 | volumes: 34 | - ./database/mysql:/var/lib/mysql 35 | environment: 36 | MYSQL_DATABASE: ${MYSQL_DATABASE} 37 | MYSQL_USER: ${MYSQL_USER} 38 | MYSQL_PASSWORD: ${MYSQL_PASSWORD} 39 | MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Matthew Tonkin-Dunn 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenCart Docker 2 | 3 | This repository should make it super simple to run [Opencart](http://www.opencart.com/) in docker containers. 4 | 5 | ## Installation 6 | 1. Firstly, create a project folder and place the OpenCart files insde there. 7 | 2. Add the opencart-docker files: 8 | - if you are using Git already you could add it as a submodule: 9 | 10 | $ git submodule add https://github.com/DockerIt/opencart-docker.git 11 | - if not, either copy the files or clone into the project directory: 12 | 13 | $ git clone https://github.com/DockerIt/opencart-docker.git 14 | 3. It should look a bit like this: 15 | 16 | |-- project-root 17 | | |-- opencart-docker 18 | | |-- tests 19 | | |-- upload 20 | | |-- vendor 21 | | |-- build.xml 22 | | |-- changelog.md 23 | | |-- etc... 24 | 25 | 4. Copy the .env-example to .env and make any changes to the environment variables that you want. 26 | 27 | $ cp .env-example .env 28 | 29 | 5. Now, in the opencart-docker folder, we want run it and serve Opencart. The simplest way is: 30 | 31 | $ docker-compose up -d apache mysql 32 | 33 | 6. Finally we need to be able to access the site. We need to put the docker ip address into the HOSTS file. 34 | This will be different on different operating systems. 35 | ### Linux 36 | 1. Simple. Docker is native so open `/etc/hosts` and add 37 | 38 | 127.0.0.1 opencart.test 39 | 40 | 41 | ### Windows 42 | 1. Firstly, make sure the docker-machine is up and running and type the command `docker-machine ip` 43 | 2. Copy this value, usually `192.168.99.100` 44 | 3. Add this to your HOSTS file (usually) `C:/Windows/System32/drivers/etc/hosts` 45 | 46 | 192.168.99.100 opencart.test 47 | 48 | 7. Visit http://opencart.test/ :-) 49 | 50 | 8. The OpenCart install is now really simple. 51 | 1. Create the `config.php` files in both `upload/` and `upload/admin/`. 52 | 2. In the database configuration use the values in `.env`. 53 | The defaults are: 54 | - **hostname**: mysql 55 | - **username**: opencart 56 | - **password**: password 57 | - **database**: opencart 58 | 3. Click continue and then OpenCart should install and you should be able to access your store! 59 | -------------------------------------------------------------------------------- /php-fpm/opencart.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 = 2 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 = 1 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 = 3 68 | 69 | ;--------------------- 70 | 71 | ; Make specific Docker environment variables available to PHP 72 | env[DB_1_ENV_MYSQL_DATABASE] = $DB_1_ENV_MYSQL_DATABASE 73 | env[DB_1_ENV_MYSQL_USER] = $DB_1_ENV_MYSQL_USER 74 | env[DB_1_ENV_MYSQL_PASSWORD] = $DB_1_ENV_MYSQL_PASSWORD 75 | 76 | catch_workers_output = yes 77 | --------------------------------------------------------------------------------