magently / docker

0 stars 2 forks source link

Magently Docker Images

Docker images based on WebDevOps Dockerfile providing docker environment for PHP apps.

Image types

Base

Is is important to notice that this image is not meant to run with root permission, the main strength of this image is to provide environment which can be used with user permissions (usally with developer/CI ownership) without pain of files ownership conflicts.

Given /app with user:group ownership all web-server-generated files will be created with the same user:group ownership.

Please run all app related scripts using gosu application wrapper, f.e.: gosu application composer require --dev phpunit/phpunit.

Usage

Assuming your app is placed in app directory and it contains a build.xml file, you can run this container with following docker-compose config:

version: '2'

services:
  app:
    build: ./docker/base/php5
    ports:
      - 80:80
    volumes:
      - ./app:/app

  db:
    image: mysql:5.7

Magento (M1)

Common use cases

Usage

You can use this image with simple docker-compose file:

version: '2'

services:
  # MySQL container
  db:
    image: mysql:5.6
    environment:
      - MYSQL_DATABASE=db
      - MYSQL_ROOT_PASSWORD=secret

  # App container
  app:
    image: magently/magento
    ports:
      - "80:80"
    links:
      - db
    volumes:
      - ./module:/app/packages
    environment:
      - MYSQL_HOST=db
      - MYSQL_USER=root
      - MYSQL_PASSWORD=secret
      - MYSQL_DATABASE=db

Running analysis

To run pre-configured analysis simply use those commands:

$ docker-compose exec bash -c 'cd /app && gosu application composer run-script test'

Magento2-env

This image is tuned to run Magento with lowest effort.

Usage

Assuming directory structure like below:

You can run this image with following docker-compose config:

version: '2'

services:
  # MySQL container
  db:
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: secret
      MYSQL_DATABASE: db

  # App container
  app:
    image: magently/magento2-env
    links:
      - db
    ports:
      - 80:80
    volumes:
      - ./project/:/var/www/magento/
      - ./packages/:/var/www/magento/packages/
    environment:
      - MYSQL_HOST=db
      - MYSQL_USER=root
      - MYSQL_PASSWORD=secret
      - MYSQL_DATABASE=db
      - COMPOSER_AUTH={"http-basic":{"repo.magento.com":{"username":"<username>","password":"<password>"}}}

  ##
  # OPTIONALLY FOR FUNCTIONAL TESTING
  # MERGE DIRECTIVES BELOW:
  ##
    volumes:
      - ./path/to/custom/credentials.xml.tmpl:/opt/docker/magento/templates/dev/tests/functional/credentials.xml.tmpl
      - ./packages/path/to/package/Test/functional:/var/www/magento/dev/tests/functional/tests/app/<vendor>/<namespace>/Test
    environment:
      - SELENIUM_HOST=hub
      - SELENIUM_PORT=4444
      - SELENIUM_BROWSER=Mozilla Firefox
      - SELENIUM_BROWSER_NAME=firefox
    extra_hosts:
      - "magento.localhost:127.0.0.1"

  # Selenium container
  hub:
    image: selenium/hub:2.53.1
    links:
      - app:magento.localhost

  firefox:
    image: selenium/node-firefox:2.53.1
    links:
      - hub
    environment:
      HUB_PORT_4444_TCP_ADDR: hub
      HUB_PORT_4444_TCP_PORT: 4444

Having this set up you can run static-analysis and tests on every package in ./packages directory:

$ docker-compose exec bash -c 'cd /app && gosu application composer run-script test'

Magento2

This images are meant for Magento 2 integrating, you can test your packages with various Magento 2 versions easily with this image.

Tags

Usage

Assuming directory structure like below:

You can run this image with following docker-compose config:

version: '2'

services:
  # MySQL container
  db:
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: secret
      MYSQL_DATABASE: db

  # App container
  app:
    image: magently/magento2
    links:
      - db
    ports:
      - 80:80
    volumes:
      - ./packages/:/var/www/magento/packages/
    environment:
      - MYSQL_HOST=db
      - MYSQL_USER=root
      - MYSQL_PASSWORD=secret
      - MYSQL_DATABASE=db

  ##
  # OPTIONALLY FOR FUNCTIONAL TESTING:
  ##

      - SELENIUM_HOST=hub
      - SELENIUM_PORT=4444
      - SELENIUM_BROWSER=Mozilla Firefox
      - SELENIUM_BROWSER_NAME=firefox
    extra_hosts:
      - "magento.localhost:127.0.0.1"

  # Selenium container
  hub:
    image: selenium/hub:2.53.1
    links:
      - app:magento.localhost

  firefox:
    image: selenium/node-firefox:2.53.1
    links:
      - hub
    environment:
      HUB_PORT_4444_TCP_ADDR: hub
      HUB_PORT_4444_TCP_PORT: 4444

Having this set up you can run static-analysis and tests on every package in ./packages directory:

$ docker-compose exec bash -c 'cd /app && gosu application composer run-script test'