def shell(**kwargs): # todo: there is way too much logic in here user_volumes = kwargs.pop('volume', tuple()) restart_container = kwargs.pop('new', False) docker_opts = kwargs.pop("docker_opts") or " " container_name = get_container_name() env_id = generate_image_name() if get_image(env_id) is None: # Transparently build an image if one does not exist. _build_wrapper( kwargs.get("force"), kwargs.get("verbosity"), kwargs.get("dockerfile"), kwargs.get("base_image"), ) if restart_container: commit_container(temporary=True) delete_containers() if get_container(container_name) is not None: click.echo("Container exists - resuming") restart_shell(container_name) else: start_new_shell( env_id, container_name, user_volumes, docker_opts=docker_opts, env_file=kwargs.get('env_file'), ) click.echo("Exited. (Run \"devenv commit\" to save state")
def init(): click.echo("Marking directory as a developent environment") open(".devenv", "w+").close() _build_wrapper() container_name = get_container_name() env_id = generate_image_name() start_new_shell(env_id, container_name, tuple())
def clean(all=False): deleted_containers = delete_containers() if delete_containers: click.echo("Deleted containers: {containers}".format(containers=deleted_containers)) if all: image_to_delete = generate_image_name() deleted_image = delete_images(image_to_delete) if deleted_image: click.echo("Deleted image {image_name}".format(image_name=image_to_delete))
def image_name(): click.echo(generate_image_name())
def build(force=False, verbosity=1, dockerfile=None, base_image=None): if force: click.echo("Forcing new image {image_name}".format(image_name=generate_image_name())) _build_wrapper(force, verbosity, dockerfile, base_image)