I am a product engineer and have helped build software from small startups, to manipulating hundreds of millions of data points. I write API's and make tools that make developers lives easier.
Awesome! Glad you got it. One thing to keep in mind, is that each RUN command will result in another docker layer that can be cached. So its good to string them together like so:
That way, that one layer can be cached for future builds. This can also effect image sizes. running api update and so on will download other metadata and those will stay on the image. Anything added in a layer will take up space in all future layers, unless its also removed in that same layer. So when using apk (or other package managers) in docker you want to clean up afterwards. Here is how I would re-write the above to do that
RUN apk add --no-cache--virtual .build-deps \
# requirements you usually don't need to keep around but need to build libs
gcc libc-dev make \
# requirements you need to make your app run
libffi-dev mysql-client gawk \
# example installing anything that needs those build requirements
&& pip install --no-cache-dir uvicorn gunicorn \
# this will remove the deps no longer needed, as well as clean up anything else
&& apk del .build-deps gcc libc-dev make
And all that will be cached in 1 layer, and those temporary deps installed by apk won't take up any space. this is the image I took this from github.com/tiangolo/uvicorn-gunico...
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Awesome! Glad you got it. One thing to keep in mind, is that each
RUN
command will result in another docker layer that can be cached. So its good to string them together like so:That way, that one layer can be cached for future builds. This can also effect image sizes. running
api update
and so on will download other metadata and those will stay on the image. Anything added in a layer will take up space in all future layers, unless its also removed in that same layer. So when using apk (or other package managers) in docker you want to clean up afterwards. Here is how I would re-write the above to do thatAnd all that will be cached in 1 layer, and those temporary deps installed by
apk
won't take up any space. this is the image I took this fromgithub.com/tiangolo/uvicorn-gunico...