Ejemplo n.º 1
0
def install():
    loader = PackageLoader()
    package = loader.load(os.getcwd())

    client_factory = DockerClientFactory()
    client = client_factory.get_client()

    container = client.create_container(
        image=package.current_image,
        stdin_open=True,
        tty=True,
        command="pip install flask",
        working_dir=MOUNT_DIRECTORY,
        host_config=client.create_host_config(binds={
            os.getcwd(): {
                "bind": MOUNT_DIRECTORY,
                "mode": "rw"
            }
        })
    )

    dockerpty.start(client, container)

    # Update package image
    package.current_image = client.commit(container.get("Id")).get("Id")
    loader.save(os.getcwd(), package)
Ejemplo n.º 2
0
def run():
    loader = PackageLoader()
    package = loader.load(os.getcwd())

    client_factory = DockerClientFactory()
    client = client_factory.get_client()

    container = client.create_container(
        image=package.current_image,
        stdin_open=True,
        tty=True,
        command="python {}".format(package.entry_point),
        working_dir=MOUNT_DIRECTORY,
        host_config=client.create_host_config(binds={
            os.getcwd(): {
                "bind": MOUNT_DIRECTORY,
                "mode": "rw"
            }
        })
    )

    dockerpty.start(client, container)