Code
Slim a Docker image
Multi-stage, cached properly, and a fraction of the size.
Fill it in
The current one.
Keep build tools out of the final image.
Size and build time, before and after.
Your prompt
Slim this image. Order the layers by how often they change: system packages, then dependency manifests, then dependency install, then source. Copying the whole source before installing dependencies invalidates the cache on every edit, and that single line costs more developer time than the image size ever will. Multi-stage, so compilers, headers and dev dependencies never reach the runtime image. Most oversized images are a build toolchain shipped to production. Run as a non-root user, pin the base image by digest, and add a .dockerignore first: sending a 400MB build context slows every build before anything runs. Report size and cold and warm build time, before and after. The container must still start and pass a health check.
Use Slim a Docker imageOpens with everything above already filled in.
Why this works
Copying the source before installing dependencies invalidates the cache on every edit, and that one line costs more developer time than image size ever will. This reorders layers by change frequency, splits the build out, and reports size and build time both ways.