dimajanzen / dockerized-magento

A dockerized Magento Community Edition 1.9.x

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dockerized - Magento Community Edition 1.9.x

A dockerized version of "Magento Community Edition 1.9.x"

Requirements

Before you start you should install

or

You can use vagrant if you are on Windows or a Mac

Installation

  1. Make sure you have docker and docker
  2. Clone the repository
  3. Start the projects using ./magento start or docker-compose up
git clone https://github.com/andreaskoch/dockerized-magento.git && cd dockerized-magento
./magento start

During the first start of the project docker-compose will

  1. first build all docker-images referenced in the docker-compose.yml
  2. then start the containers
  3. and trigger the installer which will

Once the installation is fininished the installer will print the URL and the credentials for the backend to the installer log:

...
installer_1     | Frontend: http://127.0.0.1/
installer_1     | Backend: http://127.0.0.1/admin
installer_1     |  - Username: admin
installer_1     |  - Password: password123

Animation: Installation and first projec start

Note: The build process and the installation process will take a while if you start the project for the first time. After thats finished starting and stoping the project will be a matter of seconds.

Usage

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:

./magento <action>

Available Actons

  • start: Starts the docker containers (and triggers the installation if magento is not yet installed)
  • stop: Stops all docker containers
  • restart: Restarts all docker containers and flushes the cache
  • status: Prints the status of all docker containers
  • magerun: Executes magerun in the magento root directory
  • composer: Executes composer in the magento root directory
  • enter: Enters the bash of a given container type (e.g. php, mysql, ...)
  • destroy: Stops all containers and removes all data

Note: The magento-script is just a small wrapper arround docker-compose. You can just use docker-compose directly.

Components

Overview

The dockerized Magento project consists of the following components:

The component-diagram should give you a general idea* how all components of the "dockerized Magento" project are connected:

Dockerized Magento: Component Diagram

* 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

Even though the setup might seem complex, the usage is thanks to docker really easy.

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 on AndyK Docs

Custom Configuration

All parameters of the Magento installation are defined via environment variables that are set in the 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.

If you have started the shop before you must repeat the installation process in order to apply changes:

  1. Modify the parameters in the docker-compose.yml
  2. Shutdown the containers and remove all data (./magento destroy)
  3. Start the containers again (./magento start)

Changing the domain name

I set the default domain name to 127.0.0.1 so you can access the shop without modifying your hosts-file. But you can simply change that by replacing 127.0.0.1 with your-domain.tld.

The domain name used as the base url for the Magento installation is referenced three times in the docker-compose.yml:

installer:
  environment:
    DOMAIN: 127.0.0.1
nginx:
  domainname: 127.0.0.1
  environment:
    DOMAIN: 127.0.0.1
  1. In the DOMAIN environment variable for the installer
  2. In domainname attribute of the nginx container
  3. In the DOMAIN environment variable for the nginx container

Using a different SSL certiticate

By default I chose the snakeoil dummy certificate that is installed on Ubuntu systems. If you are on a different system or want to use a real SSL certificate for your shop you can change the environment variables of the nginx container:

  • SSL_CERTIFICATE_PATH for the path to *.pem or *.crt file
  • SSL_CERTIFICATE_KEY_PATH for the path to the *.key file
nginx:
  environment:
    SSL_CERTIFICATE_PATH: <path-to-your-certificate>
    SSL_CERTIFICATE_KEY_PATH: <path-to-your-certificates-private-key>

Adapt Magento Installation Parameters

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_:

  • ADMIN_USERNAME: The username of the admin user
  • ADMIN_FIRSTNAME: The first name of the admin user
  • ADMIN_LASTNAME: The last name of the admin user
  • ADMIN_PASSWORD: The password for the admin user
  • ADMIN_EMAIL: The email address of the admin user (Note: Make sure it has a valid syntax. Otherwise Magento will not install.)
  • ADMIN_FRONTNAME: The name of the backend route (e.g. http://127.0.0.1/admin)
installer:
  build: docker-images/installer
  environment:
		ADMIN_USERNAME: admin
		ADMIN_FIRSTNAME: Admin
		ADMIN_LASTNAME: Inistrator
		ADMIN_PASSWORD: password123
		ADMIN_FRONTNAME: admin
		ADMIN_EMAIL: admin@example.com

Change the MySQL Root User Password

I chose a very weak passwords for the MySQL root-user. You can change it by modifiying the respective environment variables for the mysql-container ... and installer because otherwise the installation will fail:

installer:
  environment:
    MYSQL_PASSWORD: <your-mysql-root-user-password>
mysql:
  environment:
    MYSQL_ROOT_PASSWORD: <your-mysql-root-user-password>

About

A dockerized Magento Community Edition 1.9.x

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Shell 92.8%Language:Nginx 7.2%