def METHOD_NAME(docker_file, docker_image, vtag, run_tests):
    old_cwd = os.getcwd()
    print("cwd is %s" % old_cwd)
    print("Attempting to build %s..." % docker_file)
    d_file = os.path.basename(docker_file)
    os.chdir(os.path.dirname(docker_file))
    new_cwd = os.getcwd()
    print("cwd is now %s" % new_cwd)
    # build the docker image
    cmd = ["docker", "build", "--no-cache", "-t", docker_image, "."]
    if vtag is not None:
        cmd.insert(2, "--build-arg")
        cmd.insert(3, "vtag=%s" % vtag)
    if run_tests:
        cmd.insert(2, "--build-arg")
        cmd.insert(3, "run_tests=1")
    print(' '.join(cmd))
    sh(cmd)
    # start a container using the new image
    retval = run(["docker", "run", "-dit", docker_image, "/bin/bash"])
    cid = retval.stdout.rstrip()
    # since `docker cp` cannot deal with globbing, we move the
    # debs to a specific folder, then, copy the folder in.
    if "ros" in docker_file:
        run(["docker", "exec", cid, "/bin/bash", "-c",
              "mkdir -p debs/; \
               mv src/ifm3d/build/*.deb debs/"])
    else:
        run(["docker", "exec", cid, "/bin/bash", "-c",
              "mkdir -p debs/; \
               mv src/ifm3d/build/*.deb debs/; \
               mv src/ifm3d-pcl-viewer/build/*.deb debs/"])
    run(["docker", "cp", "%s:%s/debs" % (cid, DOCKER_HOME_DIR), "."])
    # clean up
    run(["docker", "rm", "-f", cid])
    run(["docker", "rmi", "-f", docker_image])
    print("Changing back to %s" % old_cwd)
    os.chdir(old_cwd)