The benefits of using multi-stage Docker builds is well-known.
Using multi-stage builds with a pure Perl setup is trivial -- all it involves
is copying the
FROM perl:5.28 as builder COPY cpanfile cpanfile RUN cpanm --installdeps . FROM perl:5.28-slim COPY --from=builder /usr/local/lib/perl5 /usr/local/lib/perl5 # Do other work here
You can also copy all of /usr/local/. Either way, this is a great way to cut down image size. I was able to reduce the size of an image from almost a gigabyte to some 200MB.
If you're dealing with some compiled dependencies, then this process probably isn't so simple.