From 85c50f83e2e18fba3e724d49d72f5e8e4715be3f Mon Sep 17 00:00:00 2001 From: Cormac McCarthy Date: Mon, 15 May 2023 13:19:11 -0700 Subject: [PATCH] - Fix pack CLI not having proper permission - Add requirements.txt file to snap to install specific version of docker --- src/containerapp/azext_containerapp/_utils.py | 7 ++++++- src/containerapp/requirements.txt | 1 + src/containerapp/setup.py | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 src/containerapp/requirements.txt diff --git a/src/containerapp/azext_containerapp/_utils.py b/src/containerapp/azext_containerapp/_utils.py index f535996c908..cc48369aae7 100644 --- a/src/containerapp/azext_containerapp/_utils.py +++ b/src/containerapp/azext_containerapp/_utils.py @@ -8,6 +8,7 @@ import json import platform import docker +import stat import io import os import requests @@ -1746,7 +1747,6 @@ def is_docker_running(): def get_pack_exec_path(): try: - dir_path = os.path.dirname(os.path.realpath(__file__)) bin_folder = os.path.join(dir_path, "bin") if not os.path.exists(bin_folder): @@ -1787,6 +1787,11 @@ def get_pack_exec_path(): with open(exec_path, "wb") as f: f.write(tar.extractfile(tar_info).read()) + # Add executable permissions for the current user if they don't exist + if not os.access(exec_path, os.X_OK): + st = os.stat(exec_path) + os.chmod(exec_path, st.st_mode | stat.S_IXUSR) + return exec_path except Exception as e: # Swallow any exceptions thrown when attempting to install pack CLI diff --git a/src/containerapp/requirements.txt b/src/containerapp/requirements.txt new file mode 100644 index 00000000000..db58120b5ea --- /dev/null +++ b/src/containerapp/requirements.txt @@ -0,0 +1 @@ +docker>=6.1.2 \ No newline at end of file diff --git a/src/containerapp/setup.py b/src/containerapp/setup.py index 30c389c2379..4311722c43e 100644 --- a/src/containerapp/setup.py +++ b/src/containerapp/setup.py @@ -49,7 +49,7 @@ # TODO: Add any additional SDK dependencies here DEPENDENCIES = [ 'pycomposefile>=0.0.29', - 'docker' + 'docker>=6.1.2' ] # Install pack CLI to build runnable application images from source