Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I handle Perl module updates when maintaining docker images?

I'm working on building a docker image to be able to run all of our Perl applications. The applications require hundreds of CPAN modules to be installed. The full build of the docker image takes about an hour to complete.

After doing the initial image, I'm not sure how best to handle ongoing updates.

  1. We could keep a single Dockerfile in git, and then modify this as required, and push new builds up to dockerhub. However if the person doing the build doesn't have all of the intermediate images, then adding a single CPAN module could be an extremely tedious process, and it might take an hour before they even know if the new module installs correctly. Also it would be downloading every CPAN module again, which seems a bit risky, as there might be a breaking change in the new module.

  2. Alternatively, the person doing the build could pull the latest docker-hub image, and then install the cpan module interactively, commit the build and push the new image to dockerhub. However then we only have our dockerhub images, but not master Dockerfile.

  3. Or another option would be to create a Dockerfile for each new build, which references the previous dockerhub image. This seems overly complicated though.

Option 1) seems wrong. I'm fairly sure we don't want to be rebuilding the entire image from the base OS just to install one additional module. However being dependent on images without Dockerfiles seems risky as well.

like image 607
user1751825 Avatar asked Jul 30 '16 13:07

user1751825


People also ask

How do I keep my docker images up to date?

# Update your tags manually as needed When a new version comes out, update the tag in your docker-compose. yml , docker-compose pull , and then restart the container ( docker-compose down && docker-compose up -d ). This is simple, and robust, and means nothing will update without you knowing.

What is the best approach to speed up the installation process of application dependencies in a docker?

The easiest way to increase the speed of your Docker image build is by specifying a cached image that can be used for subsequent builds. You can specify the cached image by adding the --cache-from argument in your build config file, which will instruct Docker to build using that image as a cache source.


1 Answers

You could use the standard module installer for your underlying OS on your docker image.

For example, if its RedHat then use yum and only use CPAN when they are not available

FROM centos:centos7
  RUN  yum -y install cpanm gcc perl perl-App-cpanminus perl-Config-Tiny &&  yum clean all
  RUN cpanm install Some::Module; rm -fr root/.cpanm; exit 0

taken from here and modified

I would try to have a base image which the actual applications use

I would also avoid doing things interactively (e.g. script a dockerfile) as you want to be able to repeat the build when upstream dependencies change, which docker hub does for you.


EDIT You can convert perl modules into your own packages using dh-make-perl

You can load these into your own Ubuntu repo using reprepro or a paid solution of Artifactory

These can then be installed using apt-get when you use your repo as a source from within a dockerfile.

When I have tried a similar thing before There are a few problems

  • Your apps don't work with the latest version of modules
  • There are far more dependencies than you expected
  • Some modules wont package

Benefits are

  • You keep the build tools (gcc, etc) off the app servers
  • You know much more about your dependencies
like image 85
KeepCalmAndCarryOn Avatar answered Sep 30 '22 13:09

KeepCalmAndCarryOn