Skip to content

Commit

Permalink
fixup! Remove Gramine dependencies that are not needed at runtime
Browse files Browse the repository at this point in the history
Signed-off-by: abin <[email protected]>
  • Loading branch information
amathew3 committed May 18, 2023
1 parent b982e98 commit 7ee42be
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion gsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def extract_define_args(args):
defineargs_dict[key] = value
else:
#user specified --define with key and without value, exiting here.
print(f'Could not find define arg `{item}` value.')
print(f'Invalid value for argument `{item}`, Expected `--define {item}=True/False`')
sys.exit(1)
return defineargs_dict

Expand Down Expand Up @@ -359,6 +359,7 @@ def gsc_sign_image(args):
env.globals.update(yaml.safe_load(args.config_file))
extract_user_from_image_config(unsigned_image.attrs['Config'], env)
env.globals['args'] = extract_define_args(args)
env.tests['trueish'] = test_trueish
distro = env.globals['Distro']

distro, _ = distro.split(':')
Expand Down Expand Up @@ -537,6 +538,16 @@ def gsc_info_image(args):
sub_info.set_defaults(command=gsc_info_image)
sub_info.add_argument('image', help='Name of the graminized Docker image.')

def test_trueish(value):
value = value.casefold()
if not value or value in ('false', 'off', 'no'):
return False
if value in ('true', 'on', 'yes'):
return True
if value.isdigit():
return bool(int(value))
raise ValueError(f'Invalid value for trueish: {value!r}')

def main(args):
args = argparser.parse_args()
return args.command(args)
3 changes: 2 additions & 1 deletion templates/Dockerfile.common.sign.template
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ FROM {{image}}
COPY --from=unsigned_image /gramine/app_files/*.sig /gramine/app_files/
COPY --from=unsigned_image /gramine/app_files/*.sgx /gramine/app_files/

{% if args.remove_gramine_deps == 'true' %}
{% if args.remove_gramine_deps is trueish %}
# Temporarily switch to the root user to uninstall packages
USER root

Expand All @@ -27,3 +27,4 @@ USER root
# Switch back to original app_image user
USER {{app_user}}
{% endif %}

0 comments on commit 7ee42be

Please sign in to comment.