Giter Site home page Giter Site logo

bettercalljohn / docker-magento Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kojiromike/docker-magento

0.0 2.0 0.0 406 KB

A Magento Development Environment Made of Docker Containers

License: MIT License

Shell 36.24% PHP 13.31% Nginx 50.46%

docker-magento's Introduction

Docker for Magento 1 Extension Development

Tl;dr How do I use this?

  1. Clone it.
  2. Type docker-compose up -d.
  3. Install a Magento
  4. Mount your file share.
  5. Develop
  6. Profit!!!

How should we build this?

Normally with Magento you get a plain LAMP stack; Apache with mod_php. That's fine, but since Docker containers are so nicely isolated, I want this approach:

 ---------------------       -------------       -------
| HTTPD/FastCGI Proxy | <-> | FastCGI PHP | <-> | MySQL |
 ---------------------       -------------       -------
                                    \               /
              ------------       -----------------------
             | File Share | <-> | Data Volume Container |
              ------------       -----------------------

Separating the HTTP server from the PHP process gives us a more true-to-form web architecture where the web application server is distinct from the web server. It means we can scale and reconfigure the different server layers independently. It means we can destroy or replace a component without destroying the other containers or their data.

What do we need to get started?

  1. A container for the HTTPD. We'll build from nginx and try to configure it for FastCGI.
  2. A container for MySQL. mysql:5 should do.
  3. A container for PHP. Magento requires mcrypt, which unfortunately isn't in the Docker official PHP image, so we'll build ours from debian.
  4. A container for data volumes. The simplest docker container needs a no-op executable like true and some files. We'll start from scratch and add on from there.
  5. A container for humans to touch data volumes.

How do we set it up?

Docker has a nice tool for orchestrating multiple containers for dev environments called Compose. I defined a docker-compose file that builds and connects the aforementioned containers from its Dockerfile in each of the directories named after the service: nginx, php, mysql, data, fs. So just run docker-compose up.

How should I access the web server?

In Docker, the exposed ports run on the Docker host. If you're using boot2docker, you can get the ip with boot2docker ip. The included browse command should be a shortcut for OS X users.

How do I get to my data?

How Docker actually houses live data is a little confusing, particularly if you're viewing it from a workstation instead of the Docker daemon host, where the volume actually resides. It might help to review Docker's own documentation on the subject. Anyway, the tl;dr version is that's what the file share container is for.

How do I use the file share container?

The file share container creates a CIFS share for the Magento directory.

OS X

mkdir -p <mountpoint>
mount_smbfs -N //guest@<docker host ip>/magento_data_1 <mountpoint>

Windows

net use <drive letter>: \\guest@<docker host ip>\magento_data_1

Linux

Similar to the OS X one, probably uses mount -t cifs. I didn't try it. Alternatively, you can run docker directly on the linux machine and access its volumes directly.

(The above commands assume the file share container name is magento_data_1. That will be true if you work in a directory named magento. For how to make this work with other directory names, see my note on container names over at the tools README.)

Known issues

  • Speed: The CIFS share is a little slow. I tried to set up an NFS share, but couldn't get it working. Taking pull requests for faster shares.
  • Disappearing data: Don't panic - if you try something like docker cp or docker export on the data container it will appear unchanged. The data is safe (in fact, the data is still on the host machine even if you delete the container, as long as you don't docker rm -v it.) Try something like
docker run --volumes-from magento_data_1 debian tar x /srv/magento > export.tar

to get a snapshot of your data. (Although it might be easier just to use the share.)

docker-magento's People

Contributors

kojiromike avatar zainengineer avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.