def build_in_docker(destination_path, distribution, top_level, package_uri):
    if destination_path.exists() and not destination_path.isdir():
        raise ValueError("go away")

    volumes = {
        FilePath('/output'): destination_path,
        FilePath('/flocker'): top_level,
    }

    # Special case to allow building the currently checked out Flocker code.
    if package_uri == top_level.path:
        package_uri = '/flocker'

    tag = "clusterhq/build-%s" % (distribution,)

    build_targets_directory = top_level.descendant(BUILD_TARGETS_SEGMENTS)
    build_directory = build_targets_directory.child(distribution)
    # The <src> path must be inside the context of the build; you cannot COPY
    # ../something /something, because the first step of a docker build is to
    # send the context directory (and subdirectories) to the docker daemon.
    # To work around this, we copy a shared requirements file into the build
    # directory.
    requirements_file = build_targets_directory.child('requirements.txt')
    tmp_requirements = build_directory.child('requirements.txt')
    requirements_file.copyTo(tmp_requirements)

    return BuildSequence(
        steps=[
            DockerBuild(
                tag=tag,
                build_directory=build_directory
            ),
            DockerRun(
                tag=tag,
                volumes=volumes,
                command=[package_uri]
            ),
        ])
Badges can be created via fixture
dataset/ETHPy150Open ClusterHQ/flocker/admin/packaging.py/build_in_docker--crossover with--dataset/ETHPy150Open mozilla/django-badger/badger/tests/test_badges_py.py/BadgesPyTest.test_badges_from_fixture