Build a docker image which includes the plenv + cpanm + carton Perl toolchain. :whale: :camel:
Build a docker image which includes the plenv + cpanm + carton Perl toolchain.
Choose your Perl version by changing PLENV_VERSION
in Dockerfile
or overwrite PLENV_VERSION
with the -e
option
cd docker-perl-toolchain
docker build -t [repositoryname] .
The docker image itself is available on Docker Hub:
docker-perl-toolchain image.
Suppose you wish to run a script (corecheck.pl
) which prints the CPU information of the host. Then you would have these three files:
cpanfile
:
requires "Sys::Info", "0.78";
corecheck.pl
:
use Sys::Info;
use Sys:
:Constants qw( :device_cpu );
my $info = Sys::Info->new;
my $cpu = $info->device( CPU => %options );
printf "CPU: %s\n", scalar($cpu->identify) || 'N/A';
printf "CPU speed is %s MHz\n", $cpu->speed || 'N/A';
printf "There are %d CPUs\n" , $cpu->count || 1;
printf "CPU load: %s\n" , $cpu->load || 0;
Dockerfile
:
FROM bogaotory/perl-toolchain
ADD cpanfile /build/cpanfile
ADD corecheck.pl /build/corecheck.pl
WORKDIR build
RUN . /etc/profile \
&& carton install # This happens in the WORKDIR, modules are installed in /build/local directory
ENTRYPOINT . /etc/profile \
&& carton exec perl corecheck.pl
Here is a list of articles/posts/repos I read in order to make this Dockerfile: