OSX/Linux Docker containers installer for Magento 2

Overview

Magento 2 OSX/Linux Docker

Requirements

MacOS: Docker, docker-sync, Git

Linux: Docker, Docker-compose, Git

on Debian based OS (Example: Ubuntu, Linux Mint) use bin/docker.sh to install docker and docker-compose

Get Source

git clone https://github.com/aliuosio/mage2.docker.git

Installation

Fresh Installation (latest magento 2 version) or your running project when located in your filesystem

cd mage2.docker
chmod +x bin/*.sh
bin/install.sh

with bin/install config you can use prompts to configure install

use .env to change values after installation and activate on restart of containers

Backend

http://localhost/admin
User: mage2_admin
Password: mage2_admin123#T

Frontend

http://localhost

OSX: on first run very slow due to docker-sync update of local shop files volume in the background. See .docker-sync/daemon.log for progress

next startup after reboot of Host

bin/start.sh

Install sample data

chmod +x sample-data.sh
bin/sample-data.sh

PHP Container Usage

docker exec -it mage2_php bash

Elasticsearch Usage

** Configured automatically with install.sh **

In Magento 2 Backend stores -Configuration -Catalog -Catalog -Tab: Catalog Search

Search Engine: Elasticsearch 7.0+
Elasticsearch Server Hostname: elasticsearch

You MUST set sysctl -w vm.max_map_count=262144 on the docker host system or the elasticsearch container goes down On OSX see link: https://stackoverflow.com/questions/41192680/update-max-map-count-for-elasticsearch-docker-container-mac-host?rq=1

Mailhog Usage

Mail Client
http://localhost:8025 

In Magento 2 Backend `stores` -`Configuration` -`Advanced` -`System` 
-`Tab: SMTP Configuration and Settings (Gmail/Google/AWS/Office360 etc)`

Authentication method: NONE
SSL type: None
SMTP Host: mailhog
SMTP Port: 1025

Features

  • Fresh Install or use magento 2 project on your file system using bin/install.sh
  • Varnish Cache Container
  • alternative OSX docker-compose file using docker-sync for better performance
  • set Magento 2 Versions as configurable option of bin/ìnstall.sh
  • using watchtower container to keep the containers current
  • set project directory to where ever you want (as configurable option in .env)
  • set PHP-FPM minor Versions under 7 (7.0, 7.1, 7.2, 7.3) as configurable option
  • http basic authentication
  • container to register SSL Cert by letsencrypt (only with valid domain)
  • setup valid SSL certificates with Let's Encrypt container
  • Mailhog container
  • Magerun2 netz98 magerun CLI tools for Magento 2
  • Extra Composer Packages with Magento 2 Installer
  • both PHP GD and PHP Imagick are installed
  • PHP Xdebug as configurable option (xdebug.idekey=docker)
  • PHP Opcache enabled
  • PHP redis enabled
  • us your local User ssh keys from host in PHP container
  • set Project Name and Namespace through bin/ìnstall.sh prompt
  • create backup of .env after bin/install.sh usage
  • only create mage2_admin user on fresh install in install.sh
  • bin/install.sh creates secure MariaDB passwords and saves them to .env
  • added prompt for SSL to bin/ìnstall.sh

Todos

  • add Healtchecks to docker-compose
  • modify installer to use config flag instead of flag kickit
  • build own ElasticSearch Image with required Plugins for Magento 2
  • fix OSX Installer
  • change PHP container OS from debian to alpine
  • set Time and Zone according to host
  • map local user to php container www-data user thanks to fixuid
  • add DB Import functions and logs
  • add downloader script to clone and install App
  • modify for running Magento 2 project
  • refactor docker-compose.osx.yml
  • Exchange docker-sync with Mutagen
  • reduce the number of volumes
  • Docker letsencrypt certification Container
  • exchange MySQL with MariaDB as soon as Magento 2 Installer fixes Mariadb container again
  • make Webserver(Apache or Nginx) configurable in bin/install.sh and docker-entrypoint.sh
  • rename config_blueprints to config and move config files to .docker/config
  • simplify letsencrypt certificate embedding in nginx container
  • Nginx Header Config passes at https://securityheaders.com/

Bugs

  • fix SSL

Support

If you encounter any problems or bugs, please create an issue on GitHub.

Contribute

Please Contribute by creating a fork of this repository.
Follow the instructions here: https://help.github.com/articles/fork-a-repo/

License

License: MIT

Comments
  • SSL error on chrome / disable SSL mode

    SSL error on chrome / disable SSL mode

    Hi,

    Hope you are all well !

    I wanted to deploy locally your repository and after executing

    ./install.sh
    

    My browser (Chrome/MacOSX) displays:

    Your connection is not private
    Attackers might be trying to steal your information from mage2.local.com (for example, passwords, messages or credit cards). Learn more
    NET::ERR_CERT_INVALID
    

    Ps. mage2.local.com was changed as letsencrypt triggered it could not validate the certificate as no valid TLD.

    My questions:

    • Can you describe more how to deploy it on MacOSX ?
    • Can you tell me how to disable the SSL mode for now ?

    Thanks in advance for your insights an inputs.

    Cheers, X

    opened by ghost 25
  • add travis file

    add travis file

    • add travis-ci file
    • use docker-compose latest version
    • try to build via docker-compose (cannot use install.sh as it requires to provide magento credentials)
    opened by ghost 10
  • error by ssl letsencrypt

    error by ssl letsencrypt

    Describe the bug sudo docker-compose run --rm letsencrypt letsencrypt certonly --webroot --email [email protected] --agree-tos -w /var/www/letsencrypt -d nanamarkt.de WARNING: The PWD variable is not set. Defaulting to a blank string. ERROR: Configuration for volume app_data specifies "device" driver_opt /htdocs, but a volume with the same name uses a different "device" driver_opt (/www/wwwroot/nanamarkt/htdocs). If you wish to use the new configuration, please remove the existing volume "nanamarkt_app_data" first: $ docker volume rm nanamarkt_app_data

    To Reproduce Steps to reproduce the behavior:

    1. after install , i try to web nanamarkt.de, but i got page 404, und without SSL.
    2. i try use , sudo docker-compose run --rm letsencrypt letsencrypt certonly --webroot --email [email protected] --agree-tos -w /var/www/letsencrypt -d nanamarkt.de i got the error WARNING: The PWD variable is not set. Defaulting to a blank string. ERROR: Configuration for volume app_data specifies "device" driver_opt /htdocs, but a volume with the same name uses a different "device" driver_opt (/www/wwwroot/nanamarkt/htdocs). If you wish to use the new configuration, please remove the existing volume "nanamarkt_app_data" first: $ docker volume rm nanamarkt_app_data ps. i used the default.conf und default_ssl.conf for the nginx.

    Desktop (please complete the following information):

    • OS: [Ubuntu 18.04]
    • Browser [chrome and safari]

    Additional context if i used

    1. sudo docker-compose down -v 2.sudo docker-compose up -d i will got the error from php container ERROR: for nanamarkt_php_7.3 Cannot create container for service php: failed toCreating nanamarkt_redis_pagespeed ... done ata, flags: 0x1000: no such file or directory

    ERROR: for php Cannot create container for service php: failed to mount local volume: mount /htdocs:/var/lib/docker/volumes/nanamarkt_app_data/_data, flags: 0x1000: no such file or directory ERROR: Encountered errors while bringing up the project.

    thank you very much

    best regards lee

    opened by hermersnana 8
  • SQLSTATE[HY000] [2006] MySQL server has gone away  In InstallCommand.php line 264:    Parameter validation failed

    SQLSTATE[HY000] [2006] MySQL server has gone away In InstallCommand.php line 264: Parameter validation failed

    Describe the bug SQLSTATE[HY000] [2006] MySQL server has gone away

    In InstallCommand.php line 264:

    Parameter validation failed can not connect the MySQL. see the error info

    To Reproduce Steps to reproduce the behavior:

    1. i used the ./install.sh
    2. by the mangeto install ,i got the error as above. i try change the Host name to localhost or mysql ,or container name from sql,but it not work.

    thanks

    best regards lee

    opened by hermersnana 8
  • file_put_contents(./composer.json): failed to open stream: Permission denied

    file_put_contents(./composer.json): failed to open stream: Permission denied

    Hi,

    Hope you are all well !

    I tested on linux the ./install.sh script and I have the following error:

    docker-compose up -d
    Creating network "mage2docker_default" with the default driver
    Creating mage2_mailhog         ... done
    Creating mage2_host-settings   ... done
    Creating mage2_redis_pagespeed ... done
    Creating mage2_redis           ... done
    Creating mage2_letsencrypt     ... done
    Creating mage2_db              ... done
    Creating mage2_elasticsearch   ... done
    Creating mage2_php             ... done
    Creating mage2_nginx           ... done
    docker exec -it -u ubuntu mage2_php composer global require hirak/prestissimo;
    Changed current directory to /home/ubuntu/.composer
    
                                                                                    
      [ErrorException]                                                              
      file_put_contents(./composer.json): failed to open stream: Permission denied  
                                                                                    
    
    require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...
    

    Any ideas how to solve it ?

    Cheers, X

    opened by ghost 7
  • SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed

    SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed

    Expected behavior Mage2_db was not active at time Magneto was attempting to install

    2020-04-28 05:50:16+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.10+maria~bionic started. 2020-04-28 05:50:16+00:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config command was: mysqld -d --verbose --help --log-bin-index=/tmp/tmp.jyIaphWNlD 2020-04-28 5:50:16 0 [Warning] option 'table_definition_cache': unsigned value 18446744073709551615 adjusted to 2097152 2020-04-28 5:50:16 0 [Note] Plugin 'FEEDBACK' is disabled. 2020-04-28 5:50:16 0 [Warning] Could not open mysql.plugin table. Some options may be missing from the help text 2020-04-28 5:50:16 0 [ERROR] mysqld: unknown option '-d' 2020-04-28 5:50:16 0 [ERROR] Aborting

    Screenshots jerteske@bizbloccenter:/var/www/mage2.docker$ docker exec -it -u root mage2_php_7.3 bin/magento setup:install --db-host=db --db-name=mage2 --db-user=mage2 --db-password=mage2 --backend-frontname=admin --base-url=http://bizbloccenter.com/ --base-url-secure=https://bizbloccenter.com/ --use-secure=1 --use-secure-admin=1 --language=de_DE --timezone=Europe/Berlin --currency=EUR --admin-lastname=mage2_admin --admin-firstname=mage2_admin [email protected] --admin-user=mage2_admin --admin-password=mage2_admin123#T --cleanup-database --use-rewrites=1; SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name does not resolve

    In InstallCommand.php line 264:

    Parameter validation failed

    Desktop (please complete the following information):

    • OS: Debian 10
    • Docker: 19.03.8
    • Docker Compose: 1.25
    opened by JerTeske 6
  • Unable to complete magento installation

    Unable to complete magento installation

    Describe the bug when I run this command ./install.sh

    it reaches here and it failed [Progress: 2 / 994] Enabling Maintenance Mode...

    In Abstract.php line 144:

    SQLSTATE[HY000] [2002] No such file or directory

    In Abstract.php line 128:

    SQLSTATE[HY000] [2002] No such file or directory

    I'm using MAC 10.15.2

    opened by MuBoori 6
  • Install issue.

    Install issue.

    Describe the bug A clear and concise description of what the bug is.

    Successfully installed docker-sync-0.5.14 Parsing documentation for docker-sync-0.5.14 Done installing documentation for docker-sync after 0 seconds 1 gem installed source ~/.bash_profile

    I'm using OSX. It always logout after the above step.

    opened by trianhhuynh 5
  • er CONNECTION_REFUSED error

    er CONNECTION_REFUSED error

    Hello, I use this docker project, but i have some problems. in the .env file SHOPURI= I replaced with my website address, but it constantly resolves to http://localhost My website: http://system.oyuncustore.com.tr IP: 185.244.30.88 where could i go wrong I request your help in this matter.

    my mother tongue is turkish so i don't know much english, sorry if i didn't explain well

    opened by hozansahin 4
  • Bug - gem install docker-sync without root permissions

    Bug - gem install docker-sync without root permissions

    Hi,

    The setup script breaks on gem install docker-sync on mac osx.

    Screenshot 2019-12-15 at 13 54 50

    According the docs the can install docker sync with root permissions or with user permissions. I'll make a PR for this.

    https://docker-sync.readthedocs.io/en/latest/getting-started/installation.html

    Regards,

    opened by rakibabu 4
  • Feature - split nginx conf files into smaller chunks

    Feature - split nginx conf files into smaller chunks

    Hi @aliuosio ,

    Thanks for sharing this awesome docker build. I saw a huge chunk of locations in the nginx default.conf. Can we split this into smaller chunks so we can manage updates in the magento nginx file?

    I propose a structure Serverpilot has:

    include /etc/nginx/conf/[subdir]*.nonssl_conf;
    include /etc/nginx/conf/[subdir]/*.conf;
    

    This way we can make multiple files:

    • Nginx pagespeed
    • SSL
    • Default Magento Nginx
    • Cloudflare conf
    • etc.....

    Happy to hear your thoughts on this.

    Raki

    opened by rakibabu 4
Releases(1.17.2)
Owner
Osiozekhai Aliu
Magento 1&2 Developer
Osiozekhai Aliu
Docker-magento2 - 🐳 Docker containers with all required Magento 2 dependencies installed available as FPM through Nginx and CLI

Magento 2 Docker A collection of Docker images for running Magento 2 through nginx and on the command line. Quick Start cp composer.env.sample compose

Meanbee 454 Dec 27, 2022
A complete stack for running Symfony 5 into Docker containers using docker-compose tool and with Certbot for the HTTPS certificate.

?? Docker + PHP 7.4 + MySQL8.0 + Nginx + Certbot(HTTPS) + Symfony 5 Boilerplate ?? Edited from https://github.com/ger86/symfony-docker version -> http

null 6 Nov 9, 2022
Textpattern-installer - Textpattern plugin and theme installer for Composer

Textpattern Installer for Composer Package directory | Issues Install plugins and themes to Textpattern CMS with Composer. $ composer require rah/rah_

Jukka Svahn 7 Apr 14, 2022
Nuber is an open source container management platform it provides a front end to manage your own cloud infrastructure, using Linux Containers virtualization technology

Nuber is an open source container management platform it provides a front end to manage your own cloud infrastructure, using Linux Containers virtualization technology

null 33 Dec 14, 2022
A Magento Development Environment Made of Docker Containers

Docker for Magento 1 Extension Development Tl;dr How do I use this? Clone it. Type docker-compose up -d. Install a Magento Mount your file share. Deve

Michael A. Smith 99 May 10, 2021
Mage2click toolset to create and manage the Magento Docker development environment with mutagen.io file-sync for macOS and native filesystem mounts on Linux.

Mage2click - Magento Docker Toolset Mage2click toolset is a system-wide command-line tool for creating and managing simultaneously running Magento Doc

Mage2click 69 Nov 28, 2022
Docker-magento - Docker image for Magento 1.6 to 1.9

Docker image for Magento 1.x This repo creates a Docker image for Magento 1.x. Please note The primary goal of this repo is to create Docker images fo

Fu Cheng 144 Nov 18, 2022
Easily install PHP extension in Docker containers

Easy installation of PHP extensions in official PHP Docker images This repository contains a script that can be used to easily install a PHP extension

Michele Locati 2.8k Jan 4, 2023
Main ABRouter product repository that contains docker-compose file and orchestrates the project containers.

ABRouter-Compose ?? ABRouter is the open-source tool to perform and track A/B tests which is also known as the experiments. Additionally, feature flag

ABRouter 29 Dec 22, 2022
Universal extension installer for Magento 2, see introductory blog post here

ExtDN Installer for Magento 2 modules The installation of extensions for Magento 2 has a few scenarios to cover depending on your starting position (M

ExtDN 26 Apr 1, 2022
🐋 This project aims to broaden knowledge of system administration by using Docker: virtualizing several Docker images, creating them in a new personal virtual machine.

?? This project aims to broaden knowledge of system administration by using Docker: virtualizing several Docker images, creating them in a new personal virtual machine.

Anton Kliek 1 Jan 26, 2022
PHP Extension installer

pickle - PHP Extension installer Pickle installs PHP extensions easily on all platforms. Installation Grab the latest phar at https://github.com/Frien

null 1.6k Dec 27, 2022
This is wegare tools but all-in-one installer only, exclude GUI

All In One Installer for Wegare Tools This is wegare tools, but this is all-in-one. Here is the source https://github.com/wegare123?tab=repositories I

Helmi Amirudin 3 Jul 29, 2022
An installer package that let's you install NodeJS and NPM as a Composer dependency.

NodeJS installer for Composer This is an installer that will download NodeJS and NPM and install them in your Composer dependencies. Installation is s

TheCodingMachine 106 Sep 30, 2022
Composer installer for PHP_CodeSniffer coding standards

PHP_CodeSniffer Standards Composer Installer Plugin This composer installer plugin allows for easy installation of PHP_CodeSniffer coding standards (r

Dealerdirect 462 Dec 22, 2022
pine - A CLI installer for timber

pine - A CLI installer for timber A CLI tool written in PHP based on symfony console to easily create a WordPress (Timber) project. Installation compo

Azeem Hassni 29 Aug 24, 2022
This package provides a set of factories to be used with containers using the PSR-11 standard for an easy Doctrine integration in a project

psr-container-doctrine: Doctrine Factories for PSR-11 Containers Doctrine factories for PSR-11 containers. This package provides a set of factories to

Roave, LLC 84 Dec 14, 2022
This composer installer plugin allows for easy installation of PHP_CodeSniffer coding standards

PHP_CodeSniffer Standards Composer Installer Plugin This composer installer plugin allows for easy installation of PHP_CodeSniffer coding standards (r

PHPCSStandards 393 Feb 25, 2022