Skip to content

Commit a8facb1

Browse files
committed
generate.pl: Install tini as default ENTRYPOINT
This allows Perl programs to run under tini and handle signals correctly, particularly on SIGINT/SIGTERM.
1 parent 0104479 commit a8facb1

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

generate.pl

+24-3
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ sub die_with_sample {
6464
savedPackages="make netbase" \
6565
&& apt-mark auto '.*' > /dev/null \
6666
&& apt-mark manual $savedPackages \
67-
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
68-
&& rm -fr /var/cache/apt/* /var/lib/apt/lists/*
67+
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false
6968
EOF
7069
chomp $docker_slim_run_purge;
7170

@@ -89,6 +88,13 @@ sub die_with_sample {
8988
sha256 => "9b60767fe40752ef7a9d3f13f19060a63389a5c23acc3e9827e19b75500f81f3",
9089
);
9190

91+
# sha256 taken from http://cdn-fastly.deb.debian.org/debian/pool/main/t/tini/tini_0.18.0-1.dsc
92+
my %tini = (
93+
name => "tini-0.18.0",
94+
url => "https://github.com/krallin/tini/archive/v0.18.0.tar.gz",
95+
sha256 => "1097675352d6317b547e73f9dc7c6839fd0bb0d96dafc2e5c95506bb324049a2",
96+
);
97+
9298
die_with_sample unless defined $config->{releases};
9399
die_with_sample unless ref $config->{releases} eq "ARRAY";
94100

@@ -141,6 +147,7 @@ sub die_with_sample {
141147
for my $build (keys %builds) {
142148
$release->{url} = $url;
143149
$release->{"cpanm_dist_$_"} = $cpanm{$_} for keys %cpanm;
150+
$release->{"tini_dist_$_"} = $tini{$_} for keys %tini;
144151

145152
$release->{extra_flags} ||= '';
146153
$release->{debian_release} ||= ['buster'];
@@ -155,7 +162,9 @@ sub die_with_sample {
155162

156163
my $output = $template;
157164
$output =~ s/\{\{$_\}\}/$release->{$_}/mg
158-
for (qw(version pause extra_flags sha256 type url image cpanm_dist_name cpanm_dist_url cpanm_dist_sha256));
165+
for (
166+
qw(version pause extra_flags sha256 type url image cpanm_dist_name cpanm_dist_url cpanm_dist_sha256 tini_dist_name tini_dist_url tini_dist_sha256)
167+
);
159168
$output =~ s/\{\{args\}\}/$builds{$build}/mg;
160169

161170
if ($build =~ /slim/) {
@@ -293,12 +302,24 @@ =head1 DESCRIPTION
293302
&& {{test}} \
294303
&& make install \
295304
&& cd /usr/src \
305+
&& apt-get update \
306+
&& apt-get install -y --no-install-recommends cmake \
307+
&& curl -L {{tini_dist_url}} -o {{tini_dist_name}}.tar.gz \
308+
&& echo '{{tini_dist_sha256}} *{{tini_dist_name}}.tar.gz' | sha256sum -c - \
309+
&& tar -xzf {{tini_dist_name}}.tar.gz && cd {{tini_dist_name}} \
310+
&& CFLAGS="-DPR_SET_CHILD_SUBREAPER=36 -DPR_GET_CHILD_SUBREAPER=37" \
311+
&& cmake . && make && make install \
312+
&& cd /usr/src \
296313
&& curl -LO {{cpanm_dist_url}} \
297314
&& echo '{{cpanm_dist_sha256}} *{{cpanm_dist_name}}.tar.gz' | sha256sum -c - \
298315
&& tar -xzf {{cpanm_dist_name}}.tar.gz && cd {{cpanm_dist_name}} && perl bin/cpanm . && cd /root \
299316
&& {{docker_slim_run_purge}} \
317+
&& apt-get purge -y --auto-remove cmake \
318+
&& rm -fr /var/cache/apt/* /var/lib/apt/lists/* \
319+
&& rm -fr /usr/src/{{tini_dist_name}}* \
300320
&& rm -fr ./cpanm /root/.cpanm /usr/src/perl /usr/src/{{cpanm_dist_name}}* /tmp/*
301321
302322
WORKDIR /root
303323
324+
ENTRYPOINT ["tini","--"]
304325
CMD ["perl{{version}}","-de0"]

0 commit comments

Comments
 (0)