diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..832be6ab8 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,18 @@ +- repo: git://github.com/pre-commit/pre-commit-hooks + sha: 'v0.4.2' + hooks: + - id: check-added-large-files + - id: check-docstring-first + - id: check-merge-conflict + - id: check-yaml + - id: debug-statements + - id: end-of-file-fixer + - id: flake8 + - id: name-tests-test + exclude: 'tests/integration/testcases.py' + - id: requirements-txt-fixer + - id: trailing-whitespace +- repo: git://github.com/asottile/reorder_python_imports + sha: 3d86483455ab5bd06cc1069fdd5ac57be5463f10 + hooks: + - id: reorder-python-imports diff --git a/CHANGELOG.md b/CHANGELOG.md index 88e725da6..4f18ddbf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -202,7 +202,7 @@ The highlights: - There is a new `fig restart` command which restarts a service's containers. - Fig creates multiple containers in service by appending a number to the service name (e.g. `db_1`, `db_2`, etc). As a convenience, Fig will now give the first container an alias of the service name (e.g. `db`). - + This link alias is also a valid hostname and added to `/etc/hosts` so you can connect to linked services using their hostname. For example, instead of resolving the environment variables `DB_PORT_5432_TCP_ADDR` and `DB_PORT_5432_TCP_PORT`, you could just use the hostname `db` and port `5432` directly. - Volume definitions now support `ro` mode, expanding `~` and expanding environment variables. @@ -250,7 +250,7 @@ Thanks @ryanbrainard and @d11wtq! ------------------ - Fig now starts links when you run `fig run` or `fig up`. - + For example, if you have a `web` service which depends on a `db` service, `fig run web ...` will start the `db` service. - Environment variables can now be resolved from the environment that Fig is running in. Just specify it as a blank variable in your `fig.yml` and, if set, it'll be resolved: @@ -410,5 +410,3 @@ Big thanks to @tomstuart, @EnTeQuAk, @schickling, @aronasorman and @GeoffreyPlit ------------------ Initial release. - - diff --git a/Dockerfile b/Dockerfile index ed23e75ac..a4cc99fea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,7 @@ RUN set -ex; \ curl \ lxc \ iptables \ + libsqlite3-dev \ ; \ rm -rf /var/lib/apt/lists/* @@ -68,6 +69,8 @@ RUN pip install -r requirements.txt ADD requirements-dev.txt /code/ RUN pip install -r requirements-dev.txt +RUN pip install tox==2.1.1 + ADD . /code/ RUN python setup.py install diff --git a/README.md b/README.md index 7121f6a2d..69423111e 100644 --- a/README.md +++ b/README.md @@ -54,4 +54,4 @@ Want to help build Compose? Check out our [contributing documentation](https://g Releasing --------- -Releases are built by maintainers, following an outline of the [release process](https://github.com/docker/compose/blob/master/RELEASE_PROCESS.md). \ No newline at end of file +Releases are built by maintainers, following an outline of the [release process](https://github.com/docker/compose/blob/master/RELEASE_PROCESS.md). diff --git a/compose/cli/command.py b/compose/cli/command.py index 204ed5271..67176df27 100644 --- a/compose/cli/command.py +++ b/compose/cli/command.py @@ -1,20 +1,25 @@ -from __future__ import unicode_literals from __future__ import absolute_import -from requests.exceptions import ConnectionError, SSLError +from __future__ import unicode_literals + import logging import os import re -import six +import six +from requests.exceptions import ConnectionError +from requests.exceptions import SSLError + +from . import errors +from . import verbose_proxy +from .. import __version__ from .. import config from ..project import Project from ..service import ConfigError -from .docopt_command import DocoptCommand -from .utils import call_silently, is_mac, is_ubuntu from .docker_client import docker_client -from . import verbose_proxy -from . import errors -from .. import __version__ +from .docopt_command import DocoptCommand +from .utils import call_silently +from .utils import is_mac +from .utils import is_ubuntu log = logging.getLogger(__name__) diff --git a/compose/cli/docker_client.py b/compose/cli/docker_client.py index 244bcbef2..ad67d5639 100644 --- a/compose/cli/docker_client.py +++ b/compose/cli/docker_client.py @@ -1,7 +1,8 @@ +import os +import ssl + from docker import Client from docker import tls -import ssl -import os def docker_client(): diff --git a/compose/cli/docopt_command.py b/compose/cli/docopt_command.py index 6eeb33a31..27f4b2bd7 100644 --- a/compose/cli/docopt_command.py +++ b/compose/cli/docopt_command.py @@ -1,9 +1,11 @@ -from __future__ import unicode_literals from __future__ import absolute_import -import sys +from __future__ import unicode_literals +import sys from inspect import getdoc -from docopt import docopt, DocoptExit + +from docopt import docopt +from docopt import DocoptExit def docopt_full_help(docstring, *args, **kwargs): diff --git a/compose/cli/errors.py b/compose/cli/errors.py index 135710d43..0569c1a0d 100644 --- a/compose/cli/errors.py +++ b/compose/cli/errors.py @@ -1,4 +1,5 @@ from __future__ import absolute_import + from textwrap import dedent diff --git a/compose/cli/formatter.py b/compose/cli/formatter.py index b5b0b3c03..9ed52c4aa 100644 --- a/compose/cli/formatter.py +++ b/compose/cli/formatter.py @@ -1,6 +1,8 @@ -from __future__ import unicode_literals from __future__ import absolute_import +from __future__ import unicode_literals + import os + import texttable diff --git a/compose/cli/log_printer.py b/compose/cli/log_printer.py index 9c5d35e18..ef484ca6c 100644 --- a/compose/cli/log_printer.py +++ b/compose/cli/log_printer.py @@ -1,11 +1,11 @@ -from __future__ import unicode_literals from __future__ import absolute_import -import sys +from __future__ import unicode_literals +import sys from itertools import cycle -from .multiplexer import Multiplexer from . import colors +from .multiplexer import Multiplexer from .utils import split_buffer diff --git a/compose/cli/main.py b/compose/cli/main.py index b95a09c80..890a3c371 100644 --- a/compose/cli/main.py +++ b/compose/cli/main.py @@ -1,28 +1,32 @@ from __future__ import print_function from __future__ import unicode_literals -from inspect import getdoc -from operator import attrgetter + import logging import re import signal import sys +from inspect import getdoc +from operator import attrgetter -from docker.errors import APIError import dockerpty +from docker.errors import APIError from .. import __version__ from .. import legacy -from ..const import DEFAULT_TIMEOUT -from ..project import NoSuchService, ConfigurationError -from ..service import BuildError, NeedsBuildError from ..config import parse_environment +from ..const import DEFAULT_TIMEOUT from ..progress_stream import StreamOutputError +from ..project import ConfigurationError +from ..project import NoSuchService +from ..service import BuildError +from ..service import NeedsBuildError from .command import Command from .docopt_command import NoSuchCommand from .errors import UserError from .formatter import Formatter from .log_printer import LogPrinter -from .utils import yesno, get_version_info +from .utils import get_version_info +from .utils import yesno log = logging.getLogger(__name__) console_handler = logging.StreamHandler(sys.stderr) diff --git a/compose/cli/multiplexer.py b/compose/cli/multiplexer.py index 955af6322..b502c351b 100644 --- a/compose/cli/multiplexer.py +++ b/compose/cli/multiplexer.py @@ -1,4 +1,5 @@ from __future__ import absolute_import + from threading import Thread try: diff --git a/compose/cli/utils.py b/compose/cli/utils.py index 7f2ba2e0d..1bb497cd8 100644 --- a/compose/cli/utils.py +++ b/compose/cli/utils.py @@ -1,14 +1,16 @@ -from __future__ import unicode_literals from __future__ import absolute_import from __future__ import division +from __future__ import unicode_literals -from .. import __version__ import datetime -from docker import version as docker_py_version import os import platform -import subprocess import ssl +import subprocess + +from docker import version as docker_py_version + +from .. import __version__ def yesno(prompt, default=None): diff --git a/compose/cli/verbose_proxy.py b/compose/cli/verbose_proxy.py index a548983e1..68dfabe52 100644 --- a/compose/cli/verbose_proxy.py +++ b/compose/cli/verbose_proxy.py @@ -1,8 +1,7 @@ - import functools -from itertools import chain import logging import pprint +from itertools import chain import six diff --git a/compose/config/__init__.py b/compose/config/__init__.py index 3907e5b67..de6f10c94 100644 --- a/compose/config/__init__.py +++ b/compose/config/__init__.py @@ -1,10 +1,9 @@ -from .config import ( - DOCKER_CONFIG_KEYS, - ConfigDetails, - ConfigurationError, - find, - load, - parse_environment, - merge_environment, - get_service_name_from_net, -) # flake8: noqa +# flake8: noqa +from .config import ConfigDetails +from .config import ConfigurationError +from .config import DOCKER_CONFIG_KEYS +from .config import find +from .config import get_service_name_from_net +from .config import load +from .config import merge_environment +from .config import parse_environment diff --git a/compose/config/config.py b/compose/config/config.py index b79ef254d..ea122bc42 100644 --- a/compose/config/config.py +++ b/compose/config/config.py @@ -1,23 +1,19 @@ import logging import os import sys -import yaml from collections import namedtuple + import six +import yaml -from compose.cli.utils import find_candidates_in_parent_dirs - +from .errors import CircularReference +from .errors import ComposeFileNotFound +from .errors import ConfigurationError from .interpolation import interpolate_environment_variables -from .errors import ( - ConfigurationError, - CircularReference, - ComposeFileNotFound, -) -from .validation import ( - validate_against_schema, - validate_service_names, - validate_top_level_object -) +from .validation import validate_against_schema +from .validation import validate_service_names +from .validation import validate_top_level_object +from compose.cli.utils import find_candidates_in_parent_dirs DOCKER_CONFIG_KEYS = [ diff --git a/compose/config/interpolation.py b/compose/config/interpolation.py index 8ebcc8759..f870ab4b2 100644 --- a/compose/config/interpolation.py +++ b/compose/config/interpolation.py @@ -1,11 +1,10 @@ +import logging import os from string import Template import six from .errors import ConfigurationError - -import logging log = logging.getLogger(__name__) diff --git a/compose/config/validation.py b/compose/config/validation.py index 26f3ca8ec..8911f5ae1 100644 --- a/compose/config/validation.py +++ b/compose/config/validation.py @@ -1,9 +1,11 @@ -from functools import wraps +import json import os +from functools import wraps from docker.utils.ports import split_port -import json -from jsonschema import Draft4Validator, FormatChecker, ValidationError +from jsonschema import Draft4Validator +from jsonschema import FormatChecker +from jsonschema import ValidationError from .errors import ConfigurationError diff --git a/compose/container.py b/compose/container.py index 37ed1fe59..f727c8673 100644 --- a/compose/container.py +++ b/compose/container.py @@ -1,10 +1,12 @@ -from __future__ import unicode_literals from __future__ import absolute_import +from __future__ import unicode_literals -import six from functools import reduce -from .const import LABEL_CONTAINER_NUMBER, LABEL_SERVICE +import six + +from .const import LABEL_CONTAINER_NUMBER +from .const import LABEL_SERVICE class Container(object): diff --git a/compose/legacy.py b/compose/legacy.py index 6fbf74d69..e8f4f9573 100644 --- a/compose/legacy.py +++ b/compose/legacy.py @@ -2,7 +2,8 @@ import logging import re from .const import LABEL_VERSION -from .container import get_container_name, Container +from .container import Container +from .container import get_container_name log = logging.getLogger(__name__) diff --git a/compose/progress_stream.py b/compose/progress_stream.py index 317c6e815..1ccdb861b 100644 --- a/compose/progress_stream.py +++ b/compose/progress_stream.py @@ -1,6 +1,6 @@ +import codecs import json import os -import codecs class StreamOutputError(Exception): diff --git a/compose/project.py b/compose/project.py index 276afb543..eb395297c 100644 --- a/compose/project.py +++ b/compose/project.py @@ -1,12 +1,17 @@ -from __future__ import unicode_literals from __future__ import absolute_import -from functools import reduce +from __future__ import unicode_literals + import logging +from functools import reduce from docker.errors import APIError -from .config import get_service_name_from_net, ConfigurationError -from .const import DEFAULT_TIMEOUT, LABEL_PROJECT, LABEL_SERVICE, LABEL_ONE_OFF +from .config import ConfigurationError +from .config import get_service_name_from_net +from .const import DEFAULT_TIMEOUT +from .const import LABEL_ONE_OFF +from .const import LABEL_PROJECT +from .const import LABEL_SERVICE from .container import Container from .legacy import check_for_legacy_containers from .service import Service diff --git a/compose/service.py b/compose/service.py index 7df5618c5..05e546c43 100644 --- a/compose/service.py +++ b/compose/service.py @@ -1,33 +1,37 @@ -from __future__ import unicode_literals from __future__ import absolute_import -from collections import namedtuple +from __future__ import unicode_literals + import logging -import re import os +import re import sys +from collections import namedtuple from operator import attrgetter import six from docker.errors import APIError -from docker.utils import create_host_config, LogConfig -from docker.utils.ports import build_port_bindings, split_port +from docker.utils import create_host_config +from docker.utils import LogConfig +from docker.utils.ports import build_port_bindings +from docker.utils.ports import split_port from . import __version__ -from .config import DOCKER_CONFIG_KEYS, merge_environment -from .const import ( - DEFAULT_TIMEOUT, - LABEL_CONTAINER_NUMBER, - LABEL_ONE_OFF, - LABEL_PROJECT, - LABEL_SERVICE, - LABEL_VERSION, - LABEL_CONFIG_HASH, -) +from .config import DOCKER_CONFIG_KEYS +from .config import merge_environment +from .config.validation import VALID_NAME_CHARS +from .const import DEFAULT_TIMEOUT +from .const import LABEL_CONFIG_HASH +from .const import LABEL_CONTAINER_NUMBER +from .const import LABEL_ONE_OFF +from .const import LABEL_PROJECT +from .const import LABEL_SERVICE +from .const import LABEL_VERSION from .container import Container from .legacy import check_for_legacy_containers -from .progress_stream import stream_output, StreamOutputError -from .utils import json_hash, parallel_execute -from .config.validation import VALID_NAME_CHARS +from .progress_stream import stream_output +from .progress_stream import StreamOutputError +from .utils import json_hash +from .utils import parallel_execute log = logging.getLogger(__name__) diff --git a/compose/utils.py b/compose/utils.py index 61d6d8024..bd8922670 100644 --- a/compose/utils.py +++ b/compose/utils.py @@ -3,10 +3,11 @@ import hashlib import json import logging import sys +from Queue import Empty +from Queue import Queue +from threading import Thread from docker.errors import APIError -from Queue import Queue, Empty -from threading import Thread log = logging.getLogger(__name__) diff --git a/docs/README.md b/docs/README.md index 4d6465637..8fbad30c5 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,8 +1,8 @@ # Contributing to the Docker Compose documentation -The documentation in this directory is part of the [https://docs.docker.com](https://docs.docker.com) website. Docker uses [the Hugo static generator](http://gohugo.io/overview/introduction/) to convert project Markdown files to a static HTML site. +The documentation in this directory is part of the [https://docs.docker.com](https://docs.docker.com) website. Docker uses [the Hugo static generator](http://gohugo.io/overview/introduction/) to convert project Markdown files to a static HTML site. -You don't need to be a Hugo expert to contribute to the compose documentation. If you are familiar with Markdown, you can modify the content in the `docs` files. +You don't need to be a Hugo expert to contribute to the compose documentation. If you are familiar with Markdown, you can modify the content in the `docs` files. If you want to add a new file or change the location of the document in the menu, you do need to know a little more. @@ -23,7 +23,7 @@ If you want to add a new file or change the location of the document in the menu docker run --rm -it -e AWS_S3_BUCKET -e NOCACHE -p 8000:8000 -e DOCKERHOST "docs-base:test-tooling" hugo server --port=8000 --baseUrl=192.168.59.103 --bind=0.0.0.0 ERROR: 2015/06/13 MenuEntry's .Url is deprecated and will be removed in Hugo 0.15. Use .URL instead. 0 of 4 drafts rendered - 0 future content + 0 future content 12 pages created 0 paginator pages created 0 tags created @@ -52,7 +52,7 @@ The top of each Docker Compose documentation file contains TOML metadata. The me parent="smn_workw_compose" weight=2 +++ - + The metadata alone has this structure: @@ -64,7 +64,7 @@ The metadata alone has this structure: parent="smn_workw_compose" weight=2 +++ - + The `[menu.main]` section refers to navigation defined [in the main Docker menu](https://github.com/docker/docs-base/blob/hugo/config.toml). This metadata says *add a menu item called* Extending services in Compose *to the menu with the* `smn_workdw_compose` *identifier*. If you locate the menu in the configuration, you'll find *Create multi-container applications* is the menu title. You can move an article in the tree by specifying a new parent. You can shift the location of the item by changing its weight. Higher numbers are heavier and shift the item to the bottom of menu. Low or no numbers shift it up. @@ -73,5 +73,5 @@ You can move an article in the tree by specifying a new parent. You can shift th ## Other key documentation repositories The `docker/docs-base` repository contains [the Hugo theme and menu configuration](https://github.com/docker/docs-base). If you open the `Dockerfile` you'll see the `make docs` relies on this as a base image for building the Compose documentation. - + The `docker/docs.docker.com` repository contains [build system for building the Docker documentation site](https://github.com/docker/docs.docker.com). Fork this repository to build the entire documentation site. diff --git a/docs/index.md b/docs/index.md index 872b01588..4342b3686 100644 --- a/docs/index.md +++ b/docs/index.md @@ -161,7 +161,7 @@ Now, when you run `docker-compose up`, Compose will pull a Redis image, build an web_1 | * Running on http://0.0.0.0:5000/ web_1 | * Restarting with stat -If you're using [Docker Machine](https://docs.docker.com/machine), then `docker-machine ip MACHINE_VM` will tell you its address and you can open `http://MACHINE_VM_IP:5000` in a browser. +If you're using [Docker Machine](https://docs.docker.com/machine), then `docker-machine ip MACHINE_VM` will tell you its address and you can open `http://MACHINE_VM_IP:5000` in a browser. If you're not using Boot2docker and are on linux, then the web app should now be listening on port 5000 on your Docker daemon host. If http://0.0.0.0:5000 doesn't resolve, you can also try localhost:5000. diff --git a/docs/install.md b/docs/install.md index d71aa0800..7a2763edc 100644 --- a/docs/install.md +++ b/docs/install.md @@ -14,7 +14,7 @@ weight=4 You can run Compose on OS X and 64-bit Linux. It is currently not supported on the Windows operating system. To install Compose, you'll need to install Docker -first. +first. Depending on how your system is configured, you may require `sudo` access to install Compose. If your system requires `sudo`, you will receive "Permission @@ -26,13 +26,13 @@ To install Compose, do the following: 1. Install Docker Engine version 1.7.1 or greater: * Mac OS X installation (installs both Engine and Compose) - + * Ubuntu installation - + * other system installations - + 2. Mac OS X users are done installing. Others should continue to the next step. - + 3. Go to the repository release page. 4. Enter the `curl` command in your termial. @@ -40,9 +40,9 @@ To install Compose, do the following: The command has the following format: curl -L https://github.com/docker/compose/releases/download/VERSION_NUM/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose - + If you have problems installing with `curl`, you can use `pip` instead: `pip install -U docker-compose` - + 4. Apply executable permissions to the binary: $ chmod +x /usr/local/bin/docker-compose @@ -85,7 +85,7 @@ To uninstall Docker Compose if you installed using `curl`: To uninstall Docker Compose if you installed using `pip`: $ pip uninstall docker-compose - + >**Note**: If you get a "Permission denied" error using either of the above >methods, you probably do not have the proper permissions to remove >`docker-compose`. To force the removal, prepend `sudo` to either of the above diff --git a/docs/pre-process.sh b/docs/pre-process.sh index 75e9611f2..f1f6b7fec 100755 --- a/docs/pre-process.sh +++ b/docs/pre-process.sh @@ -13,7 +13,7 @@ content_dir=(`ls -d /docs/content/*`) # 5 Change ](word) to ](/project/word) # 6 Change ](../../ to ](/project/ # 7 Change ](../ to ](/project/word) -# +# for i in "${content_dir[@]}" do : @@ -51,11 +51,10 @@ done for i in "${docker_dir[@]}" do : - if [ -d $i ] + if [ -d $i ] then - mv $i /docs/content/ + mv $i /docs/content/ fi done rm -rf /docs/content/docker - diff --git a/docs/production.md b/docs/production.md index 600511369..3020a0c40 100644 --- a/docs/production.md +++ b/docs/production.md @@ -93,4 +93,3 @@ guide. - [Yaml file reference](yml.md) - [Compose environment variables](env.md) - [Compose command line completion](completion.md) - diff --git a/docs/rails.md b/docs/rails.md index b73be90cb..186f9b2bf 100644 --- a/docs/rails.md +++ b/docs/rails.md @@ -117,7 +117,7 @@ Finally, you need to create the database. In another terminal, run: $ docker-compose run web rake db:create -That's it. Your app should now be running on port 3000 on your Docker daemon. If you're using [Docker Machine](https://docs.docker.com/machine), then `docker-machine ip MACHINE_VM` returns the Docker host IP address. +That's it. Your app should now be running on port 3000 on your Docker daemon. If you're using [Docker Machine](https://docs.docker.com/machine), then `docker-machine ip MACHINE_VM` returns the Docker host IP address. ## More Compose documentation diff --git a/docs/reference/build.md b/docs/reference/build.md index b6e27bb26..77d87def4 100644 --- a/docs/reference/build.md +++ b/docs/reference/build.md @@ -20,4 +20,4 @@ Options: Services are built once and then tagged as `project_service`, e.g., `composetest_db`. If you change a service's Dockerfile or the contents of its -build directory, run `docker-compose build` to rebuild it. \ No newline at end of file +build directory, run `docker-compose build` to rebuild it. diff --git a/docs/reference/docker-compose.md b/docs/reference/docker-compose.md index 46afba13c..6c46b31d1 100644 --- a/docs/reference/docker-compose.md +++ b/docs/reference/docker-compose.md @@ -5,7 +5,7 @@ description = "docker-compose Command Binary" keywords = ["fig, composition, compose, docker, orchestration, cli, docker-compose"] [menu.main] parent = "smn_compose_cli" -weight=-2 +weight=-2 +++ diff --git a/docs/reference/index.md b/docs/reference/index.md index 5651e5bf0..e7a07b09a 100644 --- a/docs/reference/index.md +++ b/docs/reference/index.md @@ -5,7 +5,7 @@ description = "Compose CLI reference" keywords = ["fig, composition, compose, docker, orchestration, cli, reference"] [menu.main] identifier = "smn_compose_cli" -parent = "smn_compose_ref" +parent = "smn_compose_ref" +++ @@ -15,7 +15,7 @@ The following pages describe the usage information for the [docker-compose](/ref * [build](/reference/build.md) * [help](/reference/help.md) -* [kill](/reference/kill.md) +* [kill](/reference/kill.md) * [ps](/reference/ps.md) * [restart](/reference/restart.md) * [run](/reference/run.md) @@ -23,7 +23,7 @@ The following pages describe the usage information for the [docker-compose](/ref * [up](/reference/up.md) * [logs](/reference/logs.md) * [port](/reference/port.md) -* [pull](/reference/pull.md) +* [pull](/reference/pull.md) * [rm](/reference/rm.md) * [scale](/reference/scale.md) * [stop](/reference/stop.md) diff --git a/docs/reference/kill.md b/docs/reference/kill.md index e5dd05736..dc4bf23a1 100644 --- a/docs/reference/kill.md +++ b/docs/reference/kill.md @@ -21,4 +21,4 @@ Options: Forces running containers to stop by sending a `SIGKILL` signal. Optionally the signal can be passed, for example: - $ docker-compose kill -s SIGINT \ No newline at end of file + $ docker-compose kill -s SIGINT diff --git a/docs/reference/overview.md b/docs/reference/overview.md index 458dea404..7425aa5e8 100644 --- a/docs/reference/overview.md +++ b/docs/reference/overview.md @@ -5,7 +5,7 @@ description = "Introduction to the CLI" keywords = ["fig, composition, compose, docker, orchestration, cli, reference"] [menu.main] parent = "smn_compose_cli" -weight=-2 +weight=-2 +++ diff --git a/docs/reference/port.md b/docs/reference/port.md index 76f93f239..c946a97d3 100644 --- a/docs/reference/port.md +++ b/docs/reference/port.md @@ -20,4 +20,4 @@ Options: instances of a service [default: 1] ``` -Prints the public port for a port binding. \ No newline at end of file +Prints the public port for a port binding. diff --git a/docs/reference/pull.md b/docs/reference/pull.md index e5b5d166f..d655dd93b 100644 --- a/docs/reference/pull.md +++ b/docs/reference/pull.md @@ -15,4 +15,4 @@ parent = "smn_compose_cli" Usage: pull [options] [SERVICE...] ``` -Pulls service images. \ No newline at end of file +Pulls service images. diff --git a/docs/reference/run.md b/docs/reference/run.md index 93ae0212b..c1efb9a77 100644 --- a/docs/reference/run.md +++ b/docs/reference/run.md @@ -27,7 +27,7 @@ Options: -T Disable pseudo-tty allocation. By default `docker-compose run` allocates a TTY. ``` -Runs a one-time command against a service. For example, the following command starts the `web` service and runs `bash` as its command. +Runs a one-time command against a service. For example, the following command starts the `web` service and runs `bash` as its command. $ docker-compose run web bash @@ -52,7 +52,3 @@ This would open up an interactive PostgreSQL shell for the linked `db` container If you do not want the `run` command to start linked containers, specify the `--no-deps` flag: $ docker-compose run --no-deps web python manage.py shell - - - - diff --git a/docs/reference/scale.md b/docs/reference/scale.md index 954183009..75140ee9e 100644 --- a/docs/reference/scale.md +++ b/docs/reference/scale.md @@ -18,4 +18,4 @@ Sets the number of containers to run for a service. Numbers are specified as arguments in the form `service=num`. For example: - $ docker-compose scale web=2 worker=3 \ No newline at end of file + $ docker-compose scale web=2 worker=3 diff --git a/docs/wordpress.md b/docs/wordpress.md index 8440fdbb4..ab22e2a0d 100644 --- a/docs/wordpress.md +++ b/docs/wordpress.md @@ -13,7 +13,7 @@ weight=6 # Quickstart Guide: Compose and Wordpress You can use Compose to easily run Wordpress in an isolated environment built -with Docker containers. +with Docker containers. ## Define the project @@ -36,7 +36,7 @@ your Dockerfile should be: ADD . /code This tells Docker how to build an image defining a container that contains PHP -and Wordpress. +and Wordpress. Next you'll create a `docker-compose.yml` file that will start your web service and a separate MySQL instance: @@ -108,7 +108,7 @@ Second, `router.php` tells PHP's built-in web server how to run Wordpress: With those four files in place, run `docker-compose up` inside your Wordpress directory and it'll pull and build the needed images, and then start the web and -database containers. If you're using [Docker Machine](https://docs.docker.com/machine), then `docker-machine ip MACHINE_VM` gives you the machine address and you can open `http://MACHINE_VM_IP:8000` in a browser. +database containers. If you're using [Docker Machine](https://docs.docker.com/machine), then `docker-machine ip MACHINE_VM` gives you the machine address and you can open `http://MACHINE_VM_IP:8000` in a browser. ## More Compose documentation diff --git a/docs/yml.md b/docs/yml.md index 966220864..6fb31a7db 100644 --- a/docs/yml.md +++ b/docs/yml.md @@ -19,7 +19,7 @@ As with `docker run`, options specified in the Dockerfile (e.g., `CMD`, `EXPOSE`, `VOLUME`, `ENV`) are respected by default - you don't need to specify them again in `docker-compose.yml`. -Values for configuration options can contain environment variables, e.g. +Values for configuration options can contain environment variables, e.g. `image: postgres:${POSTGRES_VERSION}`. For more details, see the section on [variable substitution](#variable-substitution). @@ -353,7 +353,7 @@ Custom DNS search domains. Can be a single value or a list. ### devices -List of device mappings. Uses the same format as the `--device` docker +List of device mappings. Uses the same format as the `--device` docker client create option. devices: @@ -433,4 +433,3 @@ dollar sign (`$$`). - [Command line reference](/reference) - [Compose environment variables](env.md) - [Compose command line completion](completion.md) - diff --git a/requirements-dev.txt b/requirements-dev.txt index c5d9c1064..97fc4fed8 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,7 +1,7 @@ +coverage==3.7.1 +flake8==2.3.0 +git+https://github.com/pyinstaller/pyinstaller.git@12e40471c77f588ea5be352f7219c873ddaae056#egg=pyinstaller mock >= 1.0.1 nose==1.3.4 -git+https://github.com/pyinstaller/pyinstaller.git@12e40471c77f588ea5be352f7219c873ddaae056#egg=pyinstaller -unittest2==0.8.0 -flake8==2.3.0 pep8==1.6.1 -coverage==3.7.1 +unittest2==0.8.0 diff --git a/requirements.txt b/requirements.txt index 641687686..e93db7b36 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ PyYAML==3.10 -jsonschema==2.5.1 docker-py==1.3.1 dockerpty==0.3.4 docopt==0.6.1 +jsonschema==2.5.1 requests==2.6.1 six==1.7.3 texttable==0.8.2 diff --git a/script/test-versions b/script/test-versions index ae9620e38..d67a6f5e1 100755 --- a/script/test-versions +++ b/script/test-versions @@ -5,7 +5,7 @@ set -e >&2 echo "Running lint checks" -flake8 compose tests setup.py +tox -e pre-commit if [ "$DOCKER_VERSIONS" == "" ]; then DOCKER_VERSIONS="default" diff --git a/setup.py b/setup.py index 1f9c981d1..2f6dad7a9 100644 --- a/setup.py +++ b/setup.py @@ -1,13 +1,16 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from __future__ import unicode_literals from __future__ import absolute_import -from setuptools import setup, find_packages +from __future__ import unicode_literals + import codecs import os import re import sys +from setuptools import find_packages +from setuptools import setup + def read(*parts): path = os.path.join(os.path.dirname(__file__), *parts) diff --git a/tests/fixtures/extends/nonexistent-path-base.yml b/tests/fixtures/extends/nonexistent-path-base.yml index 1cf9a304a..4e6c82b0d 100644 --- a/tests/fixtures/extends/nonexistent-path-base.yml +++ b/tests/fixtures/extends/nonexistent-path-base.yml @@ -3,4 +3,4 @@ dnebase: command: /bin/true environment: - FOO=1 - - BAR=1 \ No newline at end of file + - BAR=1 diff --git a/tests/fixtures/extends/nonexistent-path-child.yml b/tests/fixtures/extends/nonexistent-path-child.yml index aab11459b..d3b732f2a 100644 --- a/tests/fixtures/extends/nonexistent-path-child.yml +++ b/tests/fixtures/extends/nonexistent-path-child.yml @@ -5,4 +5,4 @@ dnechild: image: busybox command: /bin/true environment: - - BAR=2 \ No newline at end of file + - BAR=2 diff --git a/tests/fixtures/longer-filename-composefile/docker-compose.yaml b/tests/fixtures/longer-filename-composefile/docker-compose.yaml index b55a9e124..a4eba2d05 100644 --- a/tests/fixtures/longer-filename-composefile/docker-compose.yaml +++ b/tests/fixtures/longer-filename-composefile/docker-compose.yaml @@ -1,3 +1,3 @@ definedinyamlnotyml: image: busybox:latest - command: top \ No newline at end of file + command: top diff --git a/tests/integration/cli_test.py b/tests/integration/cli_test.py index 38f8ee464..8bdcadd52 100644 --- a/tests/integration/cli_test.py +++ b/tests/integration/cli_test.py @@ -1,15 +1,16 @@ from __future__ import absolute_import -from operator import attrgetter -import sys + import os import shlex +import sys +from operator import attrgetter -from six import StringIO from mock import patch +from six import StringIO from .testcases import DockerClientTestCase -from compose.cli.main import TopLevelCommand from compose.cli.errors import UserError +from compose.cli.main import TopLevelCommand from compose.project import NoSuchService diff --git a/tests/integration/legacy_test.py b/tests/integration/legacy_test.py index 9913bbb0f..fa983e6d5 100644 --- a/tests/integration/legacy_test.py +++ b/tests/integration/legacy_test.py @@ -1,11 +1,11 @@ import unittest -from mock import Mock from docker.errors import APIError +from mock import Mock +from .testcases import DockerClientTestCase from compose import legacy from compose.project import Project -from .testcases import DockerClientTestCase class UtilitiesTestCase(unittest.TestCase): diff --git a/tests/integration/project_test.py b/tests/integration/project_test.py index ad2fe4fea..51619cb5e 100644 --- a/tests/integration/project_test.py +++ b/tests/integration/project_test.py @@ -1,10 +1,10 @@ from __future__ import unicode_literals +from .testcases import DockerClientTestCase from compose import config from compose.const import LABEL_PROJECT -from compose.project import Project from compose.container import Container -from .testcases import DockerClientTestCase +from compose.project import Project def build_service_dicts(service_config): diff --git a/tests/integration/resilience_test.py b/tests/integration/resilience_test.py index e0c76f299..b1faf99df 100644 --- a/tests/integration/resilience_test.py +++ b/tests/integration/resilience_test.py @@ -1,10 +1,10 @@ -from __future__ import unicode_literals from __future__ import absolute_import +from __future__ import unicode_literals import mock -from compose.project import Project from .testcases import DockerClientTestCase +from compose.project import Project class ResilienceTest(DockerClientTestCase): diff --git a/tests/integration/service_test.py b/tests/integration/service_test.py index 050a3bf62..1d53465f6 100644 --- a/tests/integration/service_test.py +++ b/tests/integration/service_test.py @@ -1,30 +1,28 @@ -from __future__ import unicode_literals from __future__ import absolute_import +from __future__ import unicode_literals + import os +import shutil +import tempfile from os import path from docker.errors import APIError from mock import patch -import tempfile -import shutil -from six import StringIO, text_type +from six import StringIO +from six import text_type -from compose import __version__ -from compose.const import ( - LABEL_CONTAINER_NUMBER, - LABEL_ONE_OFF, - LABEL_PROJECT, - LABEL_SERVICE, - LABEL_VERSION, -) -from compose.service import ( - ConfigError, - ConvergencePlan, - Service, - build_extra_hosts, -) -from compose.container import Container from .testcases import DockerClientTestCase +from compose import __version__ +from compose.const import LABEL_CONTAINER_NUMBER +from compose.const import LABEL_ONE_OFF +from compose.const import LABEL_PROJECT +from compose.const import LABEL_SERVICE +from compose.const import LABEL_VERSION +from compose.container import Container +from compose.service import build_extra_hosts +from compose.service import ConfigError +from compose.service import ConvergencePlan +from compose.service import Service def create_and_start_container(service, **override_options): diff --git a/tests/integration/state_test.py b/tests/integration/state_test.py index b124b19ff..3d4a5b5aa 100644 --- a/tests/integration/state_test.py +++ b/tests/integration/state_test.py @@ -1,13 +1,13 @@ from __future__ import unicode_literals -import tempfile -import shutil -import os -from compose import config -from compose.project import Project -from compose.const import LABEL_CONFIG_HASH +import os +import shutil +import tempfile from .testcases import DockerClientTestCase +from compose import config +from compose.const import LABEL_CONFIG_HASH +from compose.project import Project class ProjectTestCase(DockerClientTestCase): diff --git a/tests/integration/testcases.py b/tests/integration/testcases.py index a7929088b..e239010ea 100644 --- a/tests/integration/testcases.py +++ b/tests/integration/testcases.py @@ -1,11 +1,12 @@ -from __future__ import unicode_literals from __future__ import absolute_import -from compose.service import Service +from __future__ import unicode_literals + +from .. import unittest +from compose.cli.docker_client import docker_client from compose.config.config import ServiceLoader from compose.const import LABEL_PROJECT -from compose.cli.docker_client import docker_client from compose.progress_stream import stream_output -from .. import unittest +from compose.service import Service class DockerClientTestCase(unittest.TestCase): diff --git a/tests/unit/cli/docker_client_test.py b/tests/unit/cli/docker_client_test.py index 44bdbb291..6c2dc5f81 100644 --- a/tests/unit/cli/docker_client_test.py +++ b/tests/unit/cli/docker_client_test.py @@ -1,11 +1,12 @@ -from __future__ import unicode_literals from __future__ import absolute_import +from __future__ import unicode_literals + import os import mock -from tests import unittest from compose.cli import docker_client +from tests import unittest class DockerClientTestCase(unittest.TestCase): diff --git a/tests/unit/cli/verbose_proxy_test.py b/tests/unit/cli/verbose_proxy_test.py index 59417bb3e..6036974c6 100644 --- a/tests/unit/cli/verbose_proxy_test.py +++ b/tests/unit/cli/verbose_proxy_test.py @@ -1,8 +1,8 @@ -from __future__ import unicode_literals from __future__ import absolute_import -from tests import unittest +from __future__ import unicode_literals from compose.cli import verbose_proxy +from tests import unittest class VerboseProxyTestCase(unittest.TestCase): diff --git a/tests/unit/cli_test.py b/tests/unit/cli_test.py index e11f6f14a..35be4e926 100644 --- a/tests/unit/cli_test.py +++ b/tests/unit/cli_test.py @@ -1,11 +1,12 @@ -from __future__ import unicode_literals from __future__ import absolute_import +from __future__ import unicode_literals + import os -from .. import unittest import docker import mock +from .. import unittest from compose.cli.docopt_command import NoSuchCommand from compose.cli.errors import UserError from compose.cli.main import TopLevelCommand diff --git a/tests/unit/config_test.py b/tests/unit/config_test.py index e61172562..3d1a53214 100644 --- a/tests/unit/config_test.py +++ b/tests/unit/config_test.py @@ -1,9 +1,10 @@ -import mock import os import shutil import tempfile -from .. import unittest +import mock + +from .. import unittest from compose.config import config from compose.config.errors import ConfigurationError diff --git a/tests/unit/container_test.py b/tests/unit/container_test.py index c537a8cf5..e2381c7c2 100644 --- a/tests/unit/container_test.py +++ b/tests/unit/container_test.py @@ -1,9 +1,9 @@ from __future__ import unicode_literals -from .. import unittest -import mock import docker +import mock +from .. import unittest from compose.container import Container from compose.container import get_container_name diff --git a/tests/unit/interpolation_test.py b/tests/unit/interpolation_test.py index fb95422b0..7444884cb 100644 --- a/tests/unit/interpolation_test.py +++ b/tests/unit/interpolation_test.py @@ -1,7 +1,8 @@ import unittest -from compose.config.interpolation import interpolate, InvalidInterpolation from compose.config.interpolation import BlankDefaultDict as bddict +from compose.config.interpolation import interpolate +from compose.config.interpolation import InvalidInterpolation class InterpolationTest(unittest.TestCase): diff --git a/tests/unit/log_printer_test.py b/tests/unit/log_printer_test.py index e40a1f75d..bfd16affe 100644 --- a/tests/unit/log_printer_test.py +++ b/tests/unit/log_printer_test.py @@ -1,9 +1,10 @@ -from __future__ import unicode_literals from __future__ import absolute_import +from __future__ import unicode_literals + import os -from compose.cli.log_printer import LogPrinter from .. import unittest +from compose.cli.log_printer import LogPrinter class LogPrinterTest(unittest.TestCase): diff --git a/tests/unit/progress_stream_test.py b/tests/unit/progress_stream_test.py index 317b77e9f..5674f4e4e 100644 --- a/tests/unit/progress_stream_test.py +++ b/tests/unit/progress_stream_test.py @@ -1,10 +1,10 @@ -from __future__ import unicode_literals from __future__ import absolute_import -from tests import unittest +from __future__ import unicode_literals from six import StringIO from compose import progress_stream +from tests import unittest class ProgressStreamTestCase(unittest.TestCase): diff --git a/tests/unit/project_test.py b/tests/unit/project_test.py index 93bf12ff5..7d633c950 100644 --- a/tests/unit/project_test.py +++ b/tests/unit/project_test.py @@ -1,12 +1,13 @@ from __future__ import unicode_literals -from .. import unittest -from compose.service import Service -from compose.project import Project -from compose.container import Container -from compose.const import LABEL_SERVICE -import mock import docker +import mock + +from .. import unittest +from compose.const import LABEL_SERVICE +from compose.container import Container +from compose.project import Project +from compose.service import Service class ProjectTest(unittest.TestCase): diff --git a/tests/unit/service_test.py b/tests/unit/service_test.py index 2965d6c89..12bb4ac2d 100644 --- a/tests/unit/service_test.py +++ b/tests/unit/service_test.py @@ -1,25 +1,24 @@ -from __future__ import unicode_literals from __future__ import absolute_import - -from .. import unittest -import mock +from __future__ import unicode_literals import docker +import mock from docker.utils import LogConfig -from compose.service import Service +from .. import unittest +from compose.const import LABEL_ONE_OFF +from compose.const import LABEL_PROJECT +from compose.const import LABEL_SERVICE from compose.container import Container -from compose.const import LABEL_SERVICE, LABEL_PROJECT, LABEL_ONE_OFF -from compose.service import ( - ConfigError, - NeedsBuildError, - NoSuchImageError, - build_volume_binding, - get_container_data_volumes, - merge_volume_bindings, - parse_repository_tag, - parse_volume_spec, -) +from compose.service import build_volume_binding +from compose.service import ConfigError +from compose.service import get_container_data_volumes +from compose.service import merge_volume_bindings +from compose.service import NeedsBuildError +from compose.service import NoSuchImageError +from compose.service import parse_repository_tag +from compose.service import parse_volume_spec +from compose.service import Service class ServiceTest(unittest.TestCase): diff --git a/tests/unit/sort_service_test.py b/tests/unit/sort_service_test.py index f42a94748..a7e522a1d 100644 --- a/tests/unit/sort_service_test.py +++ b/tests/unit/sort_service_test.py @@ -1,5 +1,6 @@ -from compose.project import sort_service_dicts, DependencyError from .. import unittest +from compose.project import DependencyError +from compose.project import sort_service_dicts class SortServiceTest(unittest.TestCase): diff --git a/tests/unit/split_buffer_test.py b/tests/unit/split_buffer_test.py index 8eb54177a..efd99411a 100644 --- a/tests/unit/split_buffer_test.py +++ b/tests/unit/split_buffer_test.py @@ -1,7 +1,8 @@ -from __future__ import unicode_literals from __future__ import absolute_import -from compose.cli.utils import split_buffer +from __future__ import unicode_literals + from .. import unittest +from compose.cli.utils import split_buffer class SplitBufferTest(unittest.TestCase): diff --git a/tox.ini b/tox.ini index 33cdee167..3a69c5784 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,10 @@ [tox] -envlist = py26,py27 +envlist = py27,pre-commit [testenv] usedevelop=True +passenv = + LD_LIBRARY_PATH deps = -rrequirements.txt -rrequirements-dev.txt @@ -10,6 +12,14 @@ commands = nosetests -v {posargs} flake8 compose tests setup.py +[testenv:pre-commit] +skip_install = True +deps = + pre-commit +commands = + pre-commit install + pre-commit run --all-files + [flake8] # ignore line-length for now ignore = E501,E203