@@ -70,6 +70,13 @@ sub die_with_sample {
70
70
EOF
71
71
chomp $docker_slim_run_purge ;
72
72
73
+ my $docker_debug_run_install = <<'EOF' ;
74
+ apt-get update \
75
+ && apt-get install -y --no-install-recommends \
76
+ gdb
77
+ EOF
78
+ chomp $docker_debug_run_install ;
79
+
73
80
my $config = do {
74
81
open my $fh , ' <' , ' config.yml' or die " Couldn't open config" ;
75
82
local $/ ;
@@ -152,7 +159,10 @@ sub die_with_sample {
152
159
153
160
$release -> {extra_flags } ||= ' ' ;
154
161
155
- $release -> {image } = $build =~ / main/ ? ' buildpack-deps' : ' debian' ;
162
+ $release -> {image } = $build =~ / (main|debug)/ ? ' buildpack-deps' : ' debian' ;
163
+
164
+ # leading space is important for reducing diff against non-debug Dockerfiles
165
+ my $debug_flags = $build =~ / debug/ ? ' -Doptimize=-g -DEBUGGING=both' : ' ' ;
156
166
157
167
for my $debian_release (@{$release -> {debian_release }}) {
158
168
@@ -162,16 +172,25 @@ sub die_with_sample {
162
172
$output =~ s /\{\{ args\}\} / $builds {$build }/ mg ;
163
173
164
174
if ($build =~ / slim/ ) {
165
- $output =~ s /\{\{ docker_slim_run_install \}\} / $docker_slim_run_install / mg ;
166
- $output =~ s /\{\{ docker_slim_run_purge \}\} / $docker_slim_run_purge / mg ;
175
+ $output =~ s /\{\{ docker_run_install \}\} / $docker_slim_run_install / mg ;
176
+ $output =~ s /\{\{ docker_run_purge \}\} / $docker_slim_run_purge / mg ;
167
177
$output =~ s /\{\{ tag\}\} / $debian_release -slim/ mg ;
168
178
}
179
+ elsif ($build =~ / debug/ ) {
180
+ $output =~ s /\{\{ docker_run_install\}\} / $docker_debug_run_install / mg ;
181
+ # leading space important to reduce diffs against non-debug Dockerfiles
182
+ $output =~ s / \{\{ debug_flags\}\} / $debug_flags / mg ;
183
+ $output =~ s #\{\{ docker_run_purge\}\} # rm -fr /var/cache/apt/* /var/lib/apt/lists/*# mg ;
184
+ $output =~ s /\{\{ tag\}\} / $debian_release / mg ;
185
+ }
169
186
else {
170
- $output =~ s /\{\{ docker_slim_run_install \}\} / true/ mg ;
171
- $output =~ s /\{\{ docker_slim_run_purge \}\} / true/ mg ;
187
+ $output =~ s /\{\{ docker_run_install \}\} / true/ mg ;
188
+ $output =~ s /\{\{ docker_run_purge \}\} / true/ mg ;
172
189
$output =~ s /\{\{ tag\}\} / $debian_release / mg ;
173
190
}
174
191
192
+ $output =~ s / \{\{ debug_flags\}\} // mg ;
193
+
175
194
my $dir = sprintf " %i .%03i.%03i-%s -%s " , ($release -> {version } =~ / (\d +)\. (\d +)\. (\d +)/ ), $build , $debian_release ;
176
195
177
196
mkdir $dir unless -d $dir ;
@@ -292,7 +311,7 @@ =head1 DESCRIPTION
292
311
{{docker_copy_perl_patch}}
293
312
WORKDIR /usr/src/perl
294
313
295
- RUN {{docker_slim_run_install }} \
314
+ RUN {{docker_run_install }} \
296
315
&& curl -fL {{url}} -o perl-{{version}}.tar.{{type}} \
297
316
&& echo '{{sha256}} *perl-{{version}}.tar.{{type}}' | sha256sum --strict --check - \
298
317
&& tar --strip-components=1 -xaf perl-{{version}}.tar.{{type}} -C /usr/src/perl \
@@ -301,7 +320,7 @@ =head1 DESCRIPTION
301
320
&& gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
302
321
&& archBits="$(dpkg-architecture --query DEB_BUILD_ARCH_BITS)" \
303
322
&& archFlag="$([ "$archBits" = '64' ] && echo '-Duse64bitall' || echo '-Duse64bitint')" \
304
- && ./Configure -Darchname="$gnuArch" "$archFlag" {{args}} {{extra_flags}} -des \
323
+ && ./Configure -Darchname="$gnuArch" "$archFlag" {{args}} {{extra_flags}} {{debug_flags}} -des \
305
324
&& make -j$(nproc) \
306
325
&& {{test}} \
307
326
&& make install \
@@ -314,7 +333,7 @@ =head1 DESCRIPTION
314
333
# sha256 checksum is from docker-perl team, cf https://github.com/docker-library/official-images/pull/12612#issuecomment-1158288299
315
334
&& echo '{{cpm_dist_sha256}} */usr/local/bin/cpm' | sha256sum --strict --check - \
316
335
&& chmod +x /usr/local/bin/cpm \
317
- && {{docker_slim_run_purge }} \
336
+ && {{docker_run_purge }} \
318
337
&& rm -fr /root/.cpanm /usr/src/perl /usr/src/{{cpanm_dist_name}}* /tmp/* \
319
338
&& cpanm --version && cpm --version
320
339
0 commit comments