Sign inSign up

synoa/magento2

By synoa

•Updated over 9 years ago

WIP: PHP 7, Apache 2 and Magento 2 bundled into one image.

Image
0

10K+

synoa/magento2 repository overview

⁠docker.magento2

PHP7, Apache2, and Magento 2 bundled into an (almost) ready-to-go image

This is an image for DEVELOPMENT! Do not use this in production. If you run into problems, see Troubleshooting below⁠

⁠Usage

The synoa/magento2 image can be used within a docker-compose.yml for local development. See the following example file as a starting point.

version: "2"

services:
  web:
    image: synoa/magento2
    ports:
      - "80:80"
    links:
      - db
    volumes:
      - "./magento:/var/www/localhost/htdocs"
      - "./composer:/root/.composer"
    environment:
      MAGE_ADMIN_FIRST: admin
      MAGE_ADMIN_LAST: user
      MAGE_ADMIN_USER: admin
      MAGE_ADMIN_EMAIL: [email protected]
      MAGE_ADMIN_PASSWORD: password123
      MAGE_BASE_URL: "http://magento2.localhost/"
      MAGE_BACKEND_URL: "/admin"
      MAGE_DB_HOST: db
      MAGE_DB_NAME: magento2
      MAGE_DB_USER: root
      MAGE_DB_PASSWORD: pw
      MAGE_USE_REWRITE: 1
  db:
    image: mariadb:10.1
    ports:
      - "3306:3306"
    environment:
      MYSQL_ROOT_PASSWORD: pw
      MYSQL_DATABASE: magento2
    volumes:
      - ./db:/var/lib/mysql
⁠Composer

Magento 2 makes heavily usage of composer⁠, the PHP Package Manager. In Order to use Magento 2 you will need to create a Private and Public Access Key for your Magento Account, see the docs on how to⁠. Once you got your access keys, create a composer directory in the project root and add the auth.json file to it.

{
  "http-basic": {
    "repo.magento.com": {
      "username": "<PUBLIC_KEY>",
      "password": "<PRIVATE_KEY>"
    }
  }
}

This ensures updates via composer can be made if required.

⁠Environment Variables

The environment variables are especially useful when installing the "real" Magento Application using the Magento CLI tools. To do so, start the network with docker-compose up -d and connect to the web container, then change into the /var/www/localhost/htdocs/bin directory and run the following command:

$ php magento setup:install \
      --admin-firstname=${MAGE_ADMIN_FIRST} \
      --admin-lastname=${MAGE_ADMIN_LAST} \
      --admin-email=${MAGE_ADMIN_EMAIL} \
      --admin-user=${MAGE_ADMIN_USER} \
      --admin-password=${MAGE_ADMIN_PASSWORD} \
      --base-url=${MAGE_BASE_URL} \
      --backend-frontname=${MAGE_BACKEND_URL} \
      --db-host=${MAGE_DB_HOST} \
      --db-name=${MAGE_DB_NAME} \
      --db-user=${MAGE_DB_USER} \
      --db-password=${MAGE_DB_PASSWORD} \
      --use-rewrites=${MAGE_USE_REWRITE}

This command will install the Magento 2 App using the environment variables defined inside the docker-compose.yml.

⁠hosts

In order to use the http://magento2.localhost URL you need to add it to your /etc/hosts file on your computer like so:

127.0.0.1 magento2.localhost

Note: The /etc/hosts file must be edited as sudo user, e.g. with sudo vim /etc/hosts.

⁠Troubleshooting
⁠GLOB_BRACE
Notice: Use of undefined constant GLOB_BRACE - assumed ‘GLOB_BRACE’ in /var/www/localhost/htdocs/vendor/zendframework/zend-stdlib/src/Glob.php on line 64

Until Magento updates zend-stdlib, change the file vendor/zendframework/zend-stdlib/src/Glob.php manually and replace GLOB_BRACE with defined('GLOB_BRACE') ? GLOB_BRACE : 0. Relevant Magento Issue #2130⁠

The code should look like this afterwards:

$flagMap = [
    self::GLOB_MARK     => GLOB_MARK,
    self::GLOB_NOSORT   => GLOB_NOSORT,
    self::GLOB_NOCHECK  => GLOB_NOCHECK,
    self::GLOB_NOESCAPE => GLOB_NOESCAPE,
    self::GLOB_BRACE    => defined('GLOB_BRACE') ? GLOB_BRACE : 0,
    self::GLOB_ONLYDIR  => GLOB_ONLYDIR,
    self::GLOB_ERR      => GLOB_ERR,
];

Tag summary

Content type

Image

Digest

Size

218.3 MB

Last updated

over 9 years ago

docker pull synoa/magento2