Skip to content

Commit

Permalink
feat: added entrypoint support
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbraun89 authored May 1, 2023
1 parent d4d35e5 commit 0551f4a
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions nanolayer/installers/devcontainer_feature/oci_feature_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ def install(

Invoker.invoke(command)

cls._set_permanent_envs(feature_obj)
cls._set_entrypoint(feature_obj)

@classmethod
def _set_permanent_envs(cls, feature: Feature) -> None:
if feature.containerEnv is None:
def _set_entrypoint(cls, feature: Feature) -> None:
if feature.containerEnv is None and feature.entrypoint is None:
return

feature_profile_dir = Path(cls._PROFILE_DIR)
Expand All @@ -150,13 +150,19 @@ def _set_permanent_envs(cls, feature: Feature) -> None:
current_content = f.read()

modified = False
for env_name, env_value in feature.containerEnv.items():
statement = f"export {env_name}={env_value}"
if feature.containerEnv is not None:
for env_name, env_value in feature.containerEnv.items():
statement = f"export {env_name}={env_value}"
if statement not in current_content:
current_content += f"\n{statement}"
modified = True

if feature.entrypoint is not None:
statement = f"/bin/sh {feature.entrypoint}" # /bin/sh to be compatible with https://github.com/devcontainers/cli/blob/3b8e16506456b4d50d05a6056eb65cf8a28ee834/src/spec-node/singleContainer.ts#L367
if statement not in current_content:
current_content += f"\n{statement}"

modified = True

if modified:
with open(feature_profile_file, "w") as f:
f.write(current_content)
Expand Down

0 comments on commit 0551f4a

Please sign in to comment.