def create(env=None): nonlocal process, workdir workdir = create_workdir() process, url = start_server(workdir, env) conn = HTTPRunDB(url) conn.connect() return Server(url, conn, workdir)
def create(env_config=None): nonlocal container_id, workdir env_config = {} if env_config is None else env_config cmd = [ "docker", "build", "-f", "dockerfiles/mlrun-api/Dockerfile", "--build-arg", "MLRUN_PYTHON_VERSION=3.7.9", "--tag", docker_tag, ".", ] run(cmd, check=True, stdout=PIPE, cwd=project_dir_path) workdir = create_workdir(root_dir="/tmp") cmd = [ "docker", "run", "--detach", "--publish", "8080", # For debugging "--volume", f"{workdir}:/tmp", ] env_config.setdefault("MLRUN_httpdb__logs_path", "/tmp") for key, value in env_config.items(): cmd.extend(["--env", f"{key}={value}"]) cmd.append(docker_tag) out = run(cmd, stdout=PIPE, check=True) container_id = out.stdout.decode("utf-8").strip() # retrieve container bind port + host out = run(["docker", "port", container_id, "8080"], stdout=PIPE, check=True) # usually the output is something like b'0.0.0.0:49154\n' but sometimes (in GH actions) it's something like # b'0.0.0.0:49154\n:::49154\n' for some reason, so just taking the first line host = out.stdout.decode("utf-8").splitlines()[0] url = f"http://{host}" print(f"api url: {url}") check_server_up(url) conn = HTTPRunDB(url) conn.connect() return Server(url, conn, workdir)
def create(env_config=None): nonlocal container_id, workdir env_config = {} if env_config is None else env_config cmd = [ "docker", "build", "-f", "dockerfiles/mlrun-api/Dockerfile", "--tag", docker_tag, ".", ] run(cmd, check=True, stdout=PIPE, cwd=project_dir_path) workdir = create_workdir(root_dir="/tmp") cmd = [ "docker", "run", "--detach", "--publish", "8080", # For debugging "--volume", f"{workdir}:/tmp", ] env_config.setdefault("MLRUN_httpdb__logs_path", "/tmp") for key, value in env_config.items(): cmd.extend(["--env", f"{key}={value}"]) cmd.append(docker_tag) out = run(cmd, stdout=PIPE, check=True) container_id = out.stdout.decode("utf-8").strip() # retrieve container bind port + host out = run(["docker", "port", container_id, "8080"], stdout=PIPE, check=True) host = out.stdout.decode("utf-8").strip() url = f"http://{host}" print(f"api url: {url}") check_server_up(url) conn = HTTPRunDB(url) conn.connect() return Server(url, conn, workdir)