Git Product home page Git Product logo

platform-docker's Introduction

platform-docker Build Status

Platform Docker is a CLI tool for scaffolding docker-compose configuration for PHP projects, currently opinionated at PHP projects. Running platform-docker in a directory will create a multi-container application environment for local development.

Currently support is focused at Drupal 7 and Drupal 8. However there is rudimentary WordPress support. Generic PHP applications should be easy to implement.

Requirements

Installation

First, if you do not have Docker then head over to their documentation and see how to install for your machine. For OSX and Windows users, make sure you have Virtual Box installed and docker-machine configured, follow these instructions for the later and ensure you have ran docker-machine create --driver virtualbox default.

composer global require mglaman/platform-docker

Usage

Use within any directory. Until the app itself can scaffold a folder, it's expecting a folder structure of

  • /shared (if not present it will be made)
  • /www (required, this is your build)
  • /repository (not required, but opinionated this is the source of what was built.)
  • /tests (default directory it will look for Behat tests, however checks shared and www)

If you are on Mac OS X, export PLATFORM_DOCKER_MACHINE_NAME with your Docker machine name. The tool will automatically boot the machine or export its environment information as needed. For example, put 12 export PLATFORM_DOCKER_MACHINE_NAME="vmname" in your .bash_profile.

Features

Redis

There is a redis container available. Currently it can be added by adding the following to .platform-project in the root directory of the project

services:
  - redis

Solr

An Apache Solr container is available with the default server URI is http://solr:8983/solr Currently it can be added by adding the following to .platform-project in the root directory of the project

services:
  - solr

Flamegraphs

There is a helper command which patches Drupal to log xhprof items, and then turn them into a flamegraph.

Behat tests

Searches for behat.yml files, laucnches a Selenium (Firefox) container and executes tests.

Commands

Available commands:
  drush                              Runs a Drush command for environment.
  help                               Displays help for a command
  init                               Setup Platform and Docker Compose files
  link                               Displays link to local environment, with port.
  list                               Lists commands
 docker
  docker:logs                        Tails the logs of a specific service container
  docker:proxy (proxy)               Starts the nginx proxy container
  docker:rebuild                     Rebuild configurations and containers
  docker:restart (reboot)            Restarts the docker containers
  docker:ssh                         Allows for quick SSH into a service container.
  docker:stop (stop)                 Stops the docker containers
  docker:up (start)                  Starts the docker containers
 flamegraph
  flamegraph:create                  Creates a flamegraph from xhprof folder contents.
  flamegraph:setup                   Sets the project up for generating flamegrapghs.
  flamegraph:unpatch                 Unpatches index.php to stop xhprof logging.
 project
  project:behat (behat)              Runs behat test suite for project. Checks ./tests, ./www, ./shared and ./repository by default.
  project:db-sync                    Syncs database from environment to local
 provider
  provider:platformsh (platformsh)   Sets up a Platform.sh project

platform-docker's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

platform-docker's Issues

Add cache of available projects

When platform-docker runs, it should cache the name and location of projects. That way commands can be executed outside of the folder by specifying the project name (like Vagrant allows.)

Scaffold command

This command will

  • Create folder with specified name
  • Create a tests/behat folder (for future selenium container + test runner)
  • Prompt for a git repo to put in as repository folder
  • mglaman/toolstack-helper will identify stack from repo and build into www
  • containers get spun up

Add CONTRIBUTING.md

Try to declare the purpose and mission of this tool. Dish out info on how to contribute.

Only run Solr if specified

  • Add logic for conditionally adding containers, and link dependencies
  • Add method for defining if Solr should be used

platform-docker init: Cannot link non running container

When running platform-docker init I got the following error:

[Exception] Error executing docker command: Starting projectname_mariadb_1 projectname_redis_1 is up-to-date Starting projectname_phpfpm_1 ERROR: for phpfpm Cannot link to a non running container: /projectname_mariadb_1 AS /projectname_phpfpm_1/mariadb Encountered errors while bringing up the project.

Fresh install, link command is throwing exception

Matts-MacBook-xxxx mglaman$ platform-docker link -vvv
Docker environment information not exported. Attempting from PLATFORM_DOCKER_MACHINE_NAME



  [Exception]                     
  Error executing docker command  



Exception trace:
 () at /Users/mglaman/.composer/vendor/mglaman/docker-helper/src/DockerBase.php:58
 mglaman\Docker\DockerBase::runCommand() at /Users/mglaman/.composer/vendor/mglaman/docker-helper/src/Docker.php:61
 mglaman\Docker\Docker::inspect() at /Users/mglaman/.composer/vendor/mglaman/platform-docker/src/Command/LinkCommand.php:37
 mglaman\PlatformDocker\Command\LinkCommand->execute() at /Users/mglaman/.composer/vendor/symfony/console/Command/Command.php:256
 Symfony\Component\Console\Command\Command->run() at /Users/mglaman/.composer/vendor/symfony/console/Application.php:838
 Symfony\Component\Console\Application->doRunCommand() at /Users/mglaman/.composer/vendor/symfony/console/Application.php:189
 Symfony\Component\Console\Application->doRun() at /Users/mglaman/.composer/vendor/symfony/console/Application.php:120
 Symfony\Component\Console\Application->run() at /Users/mglaman/.composer/vendor/mglaman/platform-docker/platform-docker:21


link

Add provider runners

There should be a subset of provider commands

  • Platform.sh
  • Pantheon

These will allow users to create a local dev environment using this tool by tapping into those service's tools. Such as "platform-docker platformsh PROJECTID ENVIRONMENT" will run "project get projectid -e ENVIRONMENT" for them and run "platform-docker init"

Docker native doesn't follow symlinks. What should docker-platform do with _www?

Platform.sh cli configures its docroot (_www) as a symlink to ./.platform/local/builds/default/web.

When I execute platform-docker start and execute platform-docker ssh http, /var/platform/_www cannot be opened because of the symlink. Docker, afaik, doesn't allow to configure follow hosts' symlinks.

I could solve it manually configuring one of this two options:

  1. Configuring the docroot as ./platform/local/builds/default/web when initializing platform-docker
  2. Mounting ./.platform/local/builds/default/web in _www and configuring docroot with _www.

I like more the first option so I'm thinking about guessing, in InitCommand.php:51, if there is a platform.sh project builded, find which is its docroot and suggest that value to the user when prompting for docroot.

I don't know very well how platform.sh cli works with builds and if this solution is viable.

What do you think about it?

Can't install from Composer

  Problem 1
    - Installation request for mglaman/platform-docker 1.0.1 -> satisfiable by mglaman/platform-docker[1.0.1].
    - mglaman/platform-docker 1.0.1 requires mglaman/toolstack-helper dev-master -> no matching package found

Document TLD

Right now the configuration is geared to PROJECT_[NAME|ID].platform. Users will need to set up a wildcard DNS entry to point *.platform to 127.0.0.1 (or docker machine IP if non-Linux)

Improve checking docker-machine

Right now if PHP_OS is not linux it tries to execute "docker-machine start..". Instead it should check if the machine is up, then start it if not. Currently it runs a start and sleeps for one second regardless.

Update paths with ./ for local

Warning: the mapping "docker/conf/nginx.conf:/etc/nginx/conf.d/default.conf" in the volumes config for service "nginx" is ambiguous. In a future version of Docker, it will designate a "named" volume (see https://github.com/docker/docker/pull/14242). To prevent unexpected behaviour, change it to "./docker/conf/nginx.conf:/etc/nginx/conf.d/default.conf"
Warning: the mapping "docker/data:/var/lib/mysql" in the volumes config for service "mariadb" is ambiguous. In a future version of Docker, it will designate a "named" volume (see https://github.com/docker/docker/pull/14242). To prevent unexpected behaviour, change it to "./docker/data:/var/lib/mysql"
Warning: the mapping "docker/conf/mysql.cnf:/etc/mysql/my.cnf" in the volumes config for service "mariadb" is ambiguous. In a future version of Docker, it will designate a "named" volume (see https://github.com/docker/docker/pull/14242). To prevent unexpected behaviour, change it to "./docker/conf/mysql.cnf:/etc/mysql/my.cnf"
Warning: the mapping "docker/conf/solr:/opt/solr/example/solr/collection1/conf" in the volumes config for service "solr" is ambiguous. In a future version of Docker, it will designate a "named" volume (see https://github.com/docker/docker/pull/14242). To prevent unexpected behaviour, change it to "./docker/conf/solr:/opt/solr/example/solr/collection1/conf"
Warning: the mapping "docker/conf/fpm.conf:/usr/local/etc/php-fpm.conf" in the volumes config for service "phpfpm" is ambiguous. In a future version of Docker, it will designate a "named" volume (see https://github.com/docker/docker/pull/14242). To prevent unexpected behaviour, change it to "./docker/conf/fpm.conf:/usr/local/etc/php-fpm.conf"
Warning: the mapping "docker/conf/php.ini:/usr/local/etc/php/conf.d/local.ini" in the volumes config for service "phpfpm" is ambiguous. In a future version of Docker, it will designate a "named" volume (see https://github.com/docker/docker/pull/14242). To prevent unexpected behaviour, change it to "./docker/conf/php.ini:/usr/local/etc/php/conf.d/local.ini"

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.