-
Notifications
You must be signed in to change notification settings - Fork 83
extra chown command pads image size and build time #55
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
Comments
I saw the same thing in an (unrelated) Node image recently, my solution for that image was to run the node install as the non-root user. I think the |
Hi @rgschmitz1 thanks for the detailed feedback and suggestions. We don't use COPY --chown due to potential support problems with other container builders like Kaniko. If you can show the build still works with kaniko, then I think we could take a PR for this change. Separately, would you be open to a short chat to hear more about what you're doing with OpenFaaS? Alex |
Hi @alexellis , It was in the back of my mind that other container builders might not support the same flags, but I just did a quick search and it does look like It might be worth while to test out a different the approach that @LucasRoesler mentioned if the
Also, I'd be happy to send a message to fill you in on how I'm using OpenFaaS! |
Sorry for the delay in getting back to you all, I've been busy with taking care of my 7 month old and classes. I just tested out Kaniko with --- additional note --- I also noticed that the tox test generated a completely new virtualenv with root permissions, I'm not sure if it is necessary or desired to keep these test files in the final image. I'll likely create a new issue ticket with some additional recommendations to trim down the container image size. 👍🏻 |
That sounds good. @LucasRoesler do you want to go ahead and send a PR for this? |
Using the `--chown` flag during `COPY` is much faster than running `chown -R`. It also removes a layer from the image, resulting in faster and smaller builds. Resolves openfaas#55 Signed-off-by: Lucas Roesler <[email protected]>
@alexellis patched here #58 |
@alexellis also related is #59 which resolves #57 |
@alexellis and @LucasRoesler , thanks for the support! |
Using the `--chown` flag during `COPY` is much faster than running `chown -R`. It also removes a layer from the image, resulting in faster and smaller builds. Resolves openfaas#55 Signed-off-by: Lucas Roesler <[email protected]>
Using the `--chown` flag during `COPY` is much faster than running `chown -R`. It also removes a layer from the image, resulting in faster and smaller builds. Resolves #55 Signed-off-by: Lucas Roesler <[email protected]>
Using the `--chown` flag during `COPY` is much faster than running `chown -R`. It also removes a layer from the image, resulting in faster and smaller builds. Resolves openfaas#55 Signed-off-by: Lucas Roesler <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
My actions before raising this issue
Expected Behaviour
The
--chown
flag was introduced in v17.09.0-ce allows for copying files and changing ownership in one step, this would allow for copying files with non-root permissions without any additional container layer.Current Behaviour
There's an additional
RUN chown -R app:app ../
layer in several Dockerfiles that pads the overall image size and build time, this is especially noticeable as user specified requirements.txt grows.Possible Solution
Add the
--chown=app
flag to anyCOPY
command intended for non-root user (app) files, this will reduce overall build time and container image size.or alternative...
Create an additional build stage (e.g. FROM python:* AS production) and copy over necessary build artifacts after testing finishes. This may require significant tweaking to the Dockerfiles to make this solution possible (e.g. using a virtualenv), however it may result in a much smaller container image?
Steps to Reproduce (for bugs)
faas-cli template pull https://github.com/openfaas-incubator/python-flask-template
faas-cli new --lang python3-http-debian hello-python
hello-python/requirements.txt
, example belowtime faas-cli build --no-cache -f hello-python.yml
COPY
command intended for non-root user files to include--chown=app
time faas-cli build --no-cache -f hello-python.yml
Context
I'm a college student working on a capstone project involving deploying open-source cloud native applications in Kubernetes and doing a comparison against vendor specific solutions.
I'm using python-flask-templates as a basis for my own custom functions and would love to contribute in any way I can.
Your Environment
faas-cli version
):docker version
(e.g. Docker 17.0.05 ):Are you using Docker Swarm or Kubernetes (FaaS-netes)?
Kubernetes
Operating System and version (e.g. Linux, Windows, MacOS):
Code example or link to GitHub repo or gist to reproduce problem:
I can create a full gist if desired, but the requirements.txt provided in the "steps to reproduce" above matches my specific use case. To summarize my results, after implementing the first proposed solution produces a ~30 second decrease in build time and ~500mb decrease in image size.
Other diagnostic information / logs from troubleshooting guide
The text was updated successfully, but these errors were encountered: