Skip to content

Commit

Permalink
docker cpanm also install "depends-on" for when not a requires dep
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Mar 27, 2024
1 parent 90bd59e commit 57abc6a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
12 changes: 12 additions & 0 deletions docker/lib/PDL/Devops/DB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ sub module_name {
$module_name;
}

# this could also be used to layer in already-built containers
sub cpan_pkgs {
my ($self, $item) = @_;
my @cpan = $self->module_name($item);
for my $deps (@{ $item->depends }) {
unshift @cpan, @{ $self->cpan_pkgs(
$self->key_to_item->{ $deps }
) };
}
\@cpan; # order matters here - deps installed before main
}

sub apt_pkgs {
my ($self, $item) = @_;
my @apt = @{ $item->apt };
Expand Down
9 changes: 6 additions & 3 deletions docker/lib/PDL/Devops/Process/Docker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ sub run {
my $item = $self->item;
my $db = $self->db;
my $tag = $item->docker_tag;
my $module_name = $db->module_name($item);
my @cpan_pkgs = @{ $db->cpan_pkgs( $item ) };
my $main_module = pop @cpan_pkgs; # last, deps go before
my $dep_modules = join(" ", @cpan_pkgs) || 'strict';
my $apt_pkgs = join " ", @{ $db->apt_pkgs( $item ) };
my @cmd = (
qw(docker build),
qw(-f ), path($self->dockerfile_path, "Dockerfile.downstream"),
qw(-f), path($self->dockerfile_path, "Dockerfile.downstream"),
qw(-t), "pdl-dep:$tag",
( $item->graphical_display
? (
Expand All @@ -28,7 +30,8 @@ sub run {
)
: ()
),
qw(--build-arg), "CPANM_ARGS=$module_name",
qw(--build-arg), "CPANM_CONFIGURE_DEPS=$dep_modules",
qw(--build-arg), "CPANM_ARGS=$main_module",
( $apt_pkgs
? ( qw(--build-arg), "APT_PKGS=$apt_pkgs", )
: ()
Expand Down

0 comments on commit 57abc6a

Please sign in to comment.