Package: docker-dev
# Development tool for Docker and Docker Compose`docker-dev` eases common tasks involving Docker and Docker Compose indevelopment. **Its primary feature is to namespace Docker Compose projects** sothat you can easily have one project for each branch in your repository.Docker Compose projects are given a name, which default to that of the projectdirectory. This name is then prefixed to the Docker resources (e.g., images,containers) created for the Docker Compose project.`docker-dev` extends the project name to include the active branch name, andthen proxies calls to `docker-compose` so that they refer to the new projectname. For example, if your project is called "foo" and your active Git branchis "master", the Docker Compose project name will be set to "foo-master".This tool is available on PYPI as[docker-dev](https://pypi.python.org/pypi/docker-dev).## Features- Maintain isolated Docker Compose projects for branches of the same VCSrepository, even if they all share the same path. This means that`git checkout` will play nice with `docker-compose`.- Run host-level commands just before running `docker-compose build`. This isessential in some environments, such as Python where a `*.egg-info` directorymust exist at the root of the project if you mount the path on the containerto get instant code reload.- Easily run your test suites and export their output to the host. For example,you can use this to expose your test reports to your Continuous IntegrationService.## Development`docker-dev` proxies the `docker-compose` sub-commands `build`, `up` and `down`:- `docker-dev build` will run all the pre-build hooks that you haveinstalled (see below) and it'll also pull the latest version of any baseimages before actually building the images.- `docker-dev up` ensures that you get new containers on each call.- `docker-dev down` ensures that no trace of your project is left in Docker(inc. images, containers and volumes).## Testing`docker-dev test` allows you to run test suites and export their output to thehost system. It requires a Docker Compose file (`testing.dc.yml` by default)that defines all the services responsible for running the tests.Each test service has to begin with "test-" and must place its output in`/tmp/test-reports`, as the contents of this directory will later be exported tothe host. Here's an example of a Docker Compose file for testing:```yamlversion: "2"services:test-main:build: "."command: "test-runner --output-dir=/tmp/test-reports"```To prevent a name clash, the suffix "-test" is added to the Docker Composeproject name when run.No traces are left in Docker after this command is run, not even when the testsfail.## PluginsThis tool can be extended via the following types of plugins.### Project Name GeneratorIf your Docker Compose project is in a Git repository, `docker-dev` will appendthe active branch name to the name of the Docker Compose project. If you wantto override this behaviour or add support for another VCS, you'd need to createa function that computes the name; e.g.:```pythondef get_project_name(docker_compose_file_path):return 'suffix'```Finally, you have to register that function in your project's `setup.py` fileas an entry point for the group `docker_dev.project_name_generator`. E.g.,```pythonsetup(name='your-distribution',entry_points={'docker_dev.project_name_generator': ['foo = your_package:get_project_name',],},)```### Pre-Build HookTo have routines executed at the host level before building the images, youcan create a pre-build hook. For example:```pythondef hook(docker_compose_file_path, project_name):run_some_commands()```This function then has to be registered as an entry point, under the group`docker_dev.pre_build_hooks`.`docker-dev` will run all the installed pre-build hooks unconditionally.As of this writing, only one plugin is available:[docker-dev-python](https://github.com/2degrees/docker-dev-python).## CLIFor an comprehensive and up-to-date description of the CLI, run`docker-dev --help`.