Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): add git user configuration to local session #2877

Merged
merged 10 commits into from
May 12, 2022
12 changes: 9 additions & 3 deletions renku/core/session/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,19 @@ def session_start(
]

# NOTE: set git user
image_data = self.docker_client().api.inspect_image(image_name)
working_dir = image_data.get("Config", {}).get("WorkingDir", None)

if working_dir is None:
working_dir = "/home/jovyan"

environment = {}
volumes = [f"{str(client.path.resolve())}:/home/jovyan/work"]
volumes = [f"{str(client.path.resolve())}:{working_dir}/work"]
Panaetius marked this conversation as resolved.
Show resolved Hide resolved

global_git_config_path = os.path.normpath(os.path.expanduser("~/.gitconfig"))

if os.path.exists(global_git_config_path):
volumes.append(f"{global_git_config_path}:/home/jovyan/.gitconfig")
volumes.append(f"{global_git_config_path}:{working_dir}/.gitconfig")
else:
user = client.repository.get_global_user()
environment["GIT_AUTHOR_NAME"] = user.name
Expand All @@ -176,7 +182,7 @@ def session_start(
image_name,
f'jupyter notebook --NotebookApp.ip="0.0.0.0" --NotebookApp.port={DockerSessionProvider.JUPYTER_PORT}'
f' --NotebookApp.token="{auth_token}" --NotebookApp.default_url="{default_url}"'
" --NotebookApp.notebook_dir=/home/jovyan/work",
f" --NotebookApp.notebook_dir={working_dir}/work",
detach=True,
labels={"renku_project": project_name, "jupyter_token": auth_token},
ports={f"{DockerSessionProvider.JUPYTER_PORT}/tcp": None},
Expand Down