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

slim build doesn't generate optimized Dockerfile #589

Open
anferico opened this issue Oct 11, 2023 · 3 comments
Open

slim build doesn't generate optimized Dockerfile #589

anferico opened this issue Oct 11, 2023 · 3 comments

Comments

@anferico
Copy link

Expected Behavior

In addition to a minified Docker image, get an optimized Dockerfile that you can reuse to build new images.


Actual Behavior

The minified Docker image is created, but the optimized Dockerfile isn't. These are the only artifacts coming out of slim build:

  • my_docker_image-apparmor-profile
  • my_docker_image-seccomp.json
  • Dockerfile.fat
  • creport.json
  • files.tar

However, the optimized Dockerfile appears in slim build's logs:

cmd=build state=completed
cmd=build info=results status='MINIFIED' by='2.31X' size.original='18 GB' size.optimized='8.0 GB' 
cmd=build info=results image.name='my_docker_image' image.size='8.0 GB' has.data='true' 
cmd=build info=results artifacts.location='/tmp/slim-state/.slim-state/images/90bac9eb9682b042575a70af22e86057a94c09dd1bbbc52e1975954954e002d1/artifacts' 
cmd=build info=results artifacts.report='creport.json' 
cmd=build info=results artifacts.dockerfile.reversed='Dockerfile.fat' 
cmd=build info=results artifacts.dockerfile.optimized='Dockerfile' 
cmd=build info=results artifacts.seccomp='my_docker_image-seccomp.json' 
cmd=build info=results artifacts.apparmor='my_docker_image-apparmor-profile' 
cmd=build state=done

Steps to Reproduce the Problem

  1. Run slim xray on a Docker image to get a report.json file
  2. Run slim build passing report.json and targeting the Docker image you want to minify/optimize

Specifications

  • Version: linux|Transformer|1.40.4|d310b07567dc90763f5f27f94c618f057295b55d|2023-08-26_01:39:22AM
  • Platform: Ubuntu 20.04.5 LTS
@kcq
Copy link
Member

kcq commented Oct 19, 2023

@anferico this is because the build engine parameter to create the minified image now defaults to the "internal" build engine that doesn't use Docker. The Dockerfile for the output image is present only then the output build engine needs it. You can verify it by looking at the "image_build_engine" field in the "slim.report.json" file, which should say "internal".

The next release will remove that console message to avoid the confusion.

Thanks for reporting this!

@anferico
Copy link
Author

anferico commented Oct 19, 2023

@kcq Thanks for your reply 👍 I didn't understand whether it's possible to obtain an optimized Dockerfile or not though. Did I miss some important flags in the commands I ran? In fact, am I running the correct commands?

@kcq
Copy link
Member

kcq commented Nov 18, 2023

@anferico you can still get the Dockerfile for the output/optimized image if you use the 'docker' build engine. You can use the --image-build-engine flag and set the flag value to docker. That Dockerfile isn't super interesting, but it might be nice to have it either way. A good enhancement might be creating a fake Dockerfile with the internal build engine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants