Skip to content

Commit

Permalink
Fix name of Docker image generated via build-gramine
Browse files Browse the repository at this point in the history
User must provide the output Docker image name in `build-gramine <name>`
command but the generated image prepends `gsc-` which leads to a
confusion about what image name should be specified in config file.

With this commit, the generated Docker image has the name exactly as
specified in the `build-gramine` argument (without `gsc-` prepended).

Signed-off-by: jkr0103 <jitender.kumar@intel.com>
  • Loading branch information
jkr0103 committed Dec 21, 2023
1 parent 1165dda commit ef44399
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions gsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,17 @@ def gsc_build(args):

config = yaml.safe_load(args.config_file)
if 'Image' in config['Gramine']:
gramine_image_name = gsc_image_name(config['Gramine']['Image'])
gramine_image_name = config['Gramine']['Image']
if get_docker_image(docker_socket, gramine_image_name) is None:
print(f'Cannot find base-Gramine Docker image `{gramine_image_name}`.')
sys.exit(1)
# TODO: Drop support for old style base-Gramine Docker image name with GSC v1.8 release
if get_docker_image(docker_socket, gsc_image_name(gramine_image_name)) is None:
print(f'Cannot find base-Gramine Docker image `{gramine_image_name}`.')
sys.exit(1)

config['Gramine']['Image'] = gsc_image_name(gramine_image_name)
print(f'Warning: The base-Gramine Docker image `{gramine_image_name}` was generated by'
' an older version of GSC. Please re-build this image using this GSC version.'
' This warning will become an error in the future.')

print(f'Building unsigned graminized Docker image `{unsigned_image_name}` from original '
f'application image `{original_image_name}`...')
Expand Down Expand Up @@ -397,7 +404,7 @@ def gsc_build(args):

# Command 2: Build a "base Gramine" Docker image with the compiled runtime of Gramine.
def gsc_build_gramine(args):
gramine_image_name = gsc_image_name(args.image) # output base-Gramine image name
gramine_image_name = args.image # output base-Gramine image name
tmp_build_path = gsc_tmp_build_path(args.image) # pathlib obj with build artifacts

docker_socket = docker.from_env()
Expand Down
2 changes: 1 addition & 1 deletion templates/Dockerfile.common.build.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Include previously-prepared Docker image with Gramine (if any) or compile Gramine from sources
{% if Gramine.Image %}
FROM gsc-{{Gramine.Image}} AS gramine
FROM {{Gramine.Image}} AS gramine
{% else %}
{% include compile_template %}
{% endif %}
Expand Down

0 comments on commit ef44399

Please sign in to comment.