Giter VIP home page Giter VIP logo

make-docker-command's Introduction

make-docker-command

Seamlessly execute commands (composer, bower, compass) in isolation using docker and make.

# Install bower dependencies, without installing npm or bower locally
$ make bower install

# compile compass stylesheets, without installing ruby or compass locally
$ make compass build

# install composer dependencies faqster using HHVM, without installing HHVM locally
$ make composer install

make-docker-command doesn't change the syntax of your favorite commands: just prepend make, and the command runs in a docker container. It uses docker images hosted on Docker Hub, and generates files with the right user credentials.

make-docker-command currently supports the following dockerized commands:

Tip: For command invocations with an option (like --prefer-source), use make -- instead of make:

$ make -- composer install --prefer-source

make-docker-command requires Docker 1.2, and works both on Linux and OSX.

For more details about the intention and the implementation, see the make-docker-command introduction post on the marmelab blog.

Installation

Copy the content of the Makefile from this repository to the Makefile of the projects you're working on.

Sharing SSH Keys

Some commands may require SSH keys to connect to a secured repository (e.g. GitHub). make-docker-command will use the identity and hosts file declared in the DOCKER_SSH_IDENTITY and DOCKER_SSH_KNOWN_HOSTS environment variables (default to ~/.ssh/id_rsa and ~/.ssh/known_hosts).

If you don't want to enter a passphrase each time use these keys, create a new SSH key pair without passphrase and authorize it on GitHub:

$ cd ~/.ssh
$ mkdir docker_identity && cd docker_identity
$ ssh-keygen -t rsa -f id_rsa -N ''
$ ssh-keyscan -t rsa github.com > known_hosts

Then modify the environment variable to let make-docker-command use the new key:

$ export DOCKER_SSH_IDENTITY="~/.ssh/docker_identity/id_rsa"
$ export DOCKER_SSH_KNOWN_HOSTS="~/.ssh/docker_identity/known_hosts"

Performance

Commands executed in a docker container run in about the same time on Linux. On OS X, commands with lots of disk I/Os are much slower when run inside a container. This is currently addressed by the Docker core team.

Supported Commands

composer

Install composer dependencies using the marmelab/composer-hhvm docker image, running composer on HHVM (faster than PHP).

$ make composer install

The composer cache persists between runs. The vendor directory is created using the current user name and group. Private repositories are fetched using the SSH identity file.

phpunit

Run PHP unit tests using the marmelab/phpunit-hhvm docker image, running phpunit on HHVM (faster than PHP).

$ make phpunit

bower

Uses the marmelab/bower docker image, running bower on npm.

$ make bower install

The bower cache persists between runs. The bower_components directory is created using the current user name and group. Private repositories are fetched using the SSH identity file.

compass

Uses the marmelab/compass docker image, running bower on ruby.

$ make compass build

Troubleshooting

Not using sudo / root

The user executing make command must be a member of the docker group to avoid using sudo:

$ sudo groupadd docker
$ sudo gpasswd -a my_user docker
$ sudo service docker restart

WARNING: No swap limit support

This warning shouldn't prevent the command from running, but the message means that your system needs an additional LXC configuration. See the official Docker documentation for the solution.

Permission Problem For Executing HHVM

On hosts using AppArmor, docker containers can't execute commands as non-root, even if the executable bit is set for all. Try the following commands on the host:

$ apt-get install apparmor-utils
$ aa-complain /usr/bin/lxc-start
$ aa-complain /usr/bin/docker

OS X

Docker on OS X is still rough in the edges, and you'll need a custom version of boot2docker, allowing volume mounting, to get this working.

make-docker-command will only work when called from under the /Users/ directory (because that's the only directory shered between the host and the VM).

License

make-docker-command is available under the MIT license, courtesy of marmelab.

Comments and pull requests are welcome.

make-docker-command's People

Contributors

fzaninotto avatar sgoger avatar

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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.