Skip to content

Commit f8c8256

Browse files
committed
Switch from "&&" to ";" and use "apt-mark showmanual"+"ldd" method for non-slim Debian too
1 parent c718c72 commit f8c8256

File tree

20 files changed

+810
-608
lines changed

20 files changed

+810
-608
lines changed

2.4/alpine3.10/Dockerfile

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ RUN apk add --no-cache \
44
gmp-dev
55

66
# skip installing gem documentation
7-
RUN mkdir -p /usr/local/etc \
8-
&& { \
7+
RUN set -eux; \
8+
mkdir -p /usr/local/etc; \
9+
{ \
910
echo 'install: --no-document'; \
1011
echo 'update: --no-document'; \
1112
} >> /usr/local/etc/gemrc
@@ -18,9 +19,9 @@ ENV RUBYGEMS_VERSION 3.0.3
1819
# some of ruby's build scripts are written in ruby
1920
# we purge system ruby later to make sure our final image uses what we just built
2021
# readline-dev vs libedit-dev: https://bugs.ruby-lang.org/issues/11869 and https://github.com/docker-library/ruby/issues/75
21-
RUN set -ex \
22+
RUN set -eux; \
2223
\
23-
&& apk add --no-cache --virtual .ruby-builddeps \
24+
apk add --no-cache --virtual .ruby-builddeps \
2425
autoconf \
2526
bison \
2627
bzip2 \
@@ -47,65 +48,72 @@ RUN set -ex \
4748
xz \
4849
yaml-dev \
4950
zlib-dev \
51+
; \
5052
\
51-
&& wget -O ruby.tar.xz "https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz" \
52-
&& echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz" | sha256sum -c - \
53+
wget -O ruby.tar.xz "https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz"; \
54+
echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz" | sha256sum --check --strict; \
5355
\
54-
&& mkdir -p /usr/src/ruby \
55-
&& tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1 \
56-
&& rm ruby.tar.xz \
56+
mkdir -p /usr/src/ruby; \
57+
tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1; \
58+
rm ruby.tar.xz; \
5759
\
58-
&& cd /usr/src/ruby \
60+
cd /usr/src/ruby; \
5961
\
6062
# https://github.com/docker-library/ruby/issues/196
6163
# https://bugs.ruby-lang.org/issues/14387#note-13 (patch source)
6264
# https://bugs.ruby-lang.org/issues/14387#note-16 ("Therefore ncopa's patch looks good for me in general." -- only breaks glibc which doesn't matter here)
63-
&& wget -O 'thread-stack-fix.patch' 'https://bugs.ruby-lang.org/attachments/download/7081/0001-thread_pthread.c-make-get_main_stack-portable-on-lin.patch' \
64-
&& echo '3ab628a51d92fdf0d2b5835e93564857aea73e0c1de00313864a94a6255cb645 *thread-stack-fix.patch' | sha256sum -c - \
65-
&& patch -p1 -i thread-stack-fix.patch \
66-
&& rm thread-stack-fix.patch \
65+
wget -O 'thread-stack-fix.patch' 'https://bugs.ruby-lang.org/attachments/download/7081/0001-thread_pthread.c-make-get_main_stack-portable-on-lin.patch'; \
66+
echo '3ab628a51d92fdf0d2b5835e93564857aea73e0c1de00313864a94a6255cb645 *thread-stack-fix.patch' | sha256sum --check --strict; \
67+
patch -p1 -i thread-stack-fix.patch; \
68+
rm thread-stack-fix.patch; \
6769
\
6870
# hack in "ENABLE_PATH_CHECK" disabling to suppress:
6971
# warning: Insecure world writable dir
70-
&& { \
72+
{ \
7173
echo '#define ENABLE_PATH_CHECK 0'; \
7274
echo; \
7375
cat file.c; \
74-
} > file.c.new \
75-
&& mv file.c.new file.c \
76+
} > file.c.new; \
77+
mv file.c.new file.c; \
7678
\
77-
&& autoconf \
78-
&& gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
79+
autoconf; \
80+
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
7981
# the configure script does not detect isnan/isinf as macros
80-
&& export ac_cv_func_isnan=yes ac_cv_func_isinf=yes \
81-
&& ./configure \
82+
export ac_cv_func_isnan=yes ac_cv_func_isinf=yes; \
83+
./configure \
8284
--build="$gnuArch" \
8385
--disable-install-doc \
8486
--enable-shared \
85-
&& make -j "$(nproc)" \
86-
&& make install \
87+
; \
88+
make -j "$(nproc)"; \
89+
make install; \
8790
\
88-
&& runDeps="$( \
91+
runDeps="$( \
8992
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \
9093
| tr ',' '\n' \
9194
| sort -u \
9295
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
93-
)" \
94-
&& apk add --no-network --virtual .ruby-rundeps $runDeps \
96+
)"; \
97+
apk add --no-network --virtual .ruby-rundeps \
98+
$runDeps \
9599
bzip2 \
96100
ca-certificates \
97101
libffi-dev \
98102
procps \
99103
yaml-dev \
100104
zlib-dev \
101-
&& apk del --no-network .ruby-builddeps \
102-
&& cd / \
103-
&& rm -r /usr/src/ruby \
105+
; \
106+
apk del --no-network .ruby-builddeps; \
107+
\
108+
cd /; \
109+
rm -r /usr/src/ruby; \
104110
# make sure bundled "rubygems" is older than RUBYGEMS_VERSION (https://github.com/docker-library/ruby/issues/246)
105-
&& ruby -e 'exit(Gem::Version.create(ENV["RUBYGEMS_VERSION"]) > Gem::Version.create(Gem::VERSION))' \
106-
&& gem update --system "$RUBYGEMS_VERSION" && rm -r /root/.gem/ \
111+
ruby -e 'exit(Gem::Version.create(ENV["RUBYGEMS_VERSION"]) > Gem::Version.create(Gem::VERSION))'; \
112+
gem update --system "$RUBYGEMS_VERSION" && rm -r /root/.gem/; \
107113
# rough smoke test
108-
&& ruby --version && gem --version && bundle --version
114+
ruby --version; \
115+
gem --version; \
116+
bundle --version
109117

110118
# install things globally, for great justice
111119
# and don't create ".bundle" in all our apps

2.4/alpine3.9/Dockerfile

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ RUN apk add --no-cache \
44
gmp-dev
55

66
# skip installing gem documentation
7-
RUN mkdir -p /usr/local/etc \
8-
&& { \
7+
RUN set -eux; \
8+
mkdir -p /usr/local/etc; \
9+
{ \
910
echo 'install: --no-document'; \
1011
echo 'update: --no-document'; \
1112
} >> /usr/local/etc/gemrc
@@ -18,9 +19,9 @@ ENV RUBYGEMS_VERSION 3.0.3
1819
# some of ruby's build scripts are written in ruby
1920
# we purge system ruby later to make sure our final image uses what we just built
2021
# readline-dev vs libedit-dev: https://bugs.ruby-lang.org/issues/11869 and https://github.com/docker-library/ruby/issues/75
21-
RUN set -ex \
22+
RUN set -eux; \
2223
\
23-
&& apk add --no-cache --virtual .ruby-builddeps \
24+
apk add --no-cache --virtual .ruby-builddeps \
2425
autoconf \
2526
bison \
2627
bzip2 \
@@ -47,65 +48,72 @@ RUN set -ex \
4748
xz \
4849
yaml-dev \
4950
zlib-dev \
51+
; \
5052
\
51-
&& wget -O ruby.tar.xz "https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz" \
52-
&& echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz" | sha256sum -c - \
53+
wget -O ruby.tar.xz "https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz"; \
54+
echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz" | sha256sum --check --strict; \
5355
\
54-
&& mkdir -p /usr/src/ruby \
55-
&& tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1 \
56-
&& rm ruby.tar.xz \
56+
mkdir -p /usr/src/ruby; \
57+
tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1; \
58+
rm ruby.tar.xz; \
5759
\
58-
&& cd /usr/src/ruby \
60+
cd /usr/src/ruby; \
5961
\
6062
# https://github.com/docker-library/ruby/issues/196
6163
# https://bugs.ruby-lang.org/issues/14387#note-13 (patch source)
6264
# https://bugs.ruby-lang.org/issues/14387#note-16 ("Therefore ncopa's patch looks good for me in general." -- only breaks glibc which doesn't matter here)
63-
&& wget -O 'thread-stack-fix.patch' 'https://bugs.ruby-lang.org/attachments/download/7081/0001-thread_pthread.c-make-get_main_stack-portable-on-lin.patch' \
64-
&& echo '3ab628a51d92fdf0d2b5835e93564857aea73e0c1de00313864a94a6255cb645 *thread-stack-fix.patch' | sha256sum -c - \
65-
&& patch -p1 -i thread-stack-fix.patch \
66-
&& rm thread-stack-fix.patch \
65+
wget -O 'thread-stack-fix.patch' 'https://bugs.ruby-lang.org/attachments/download/7081/0001-thread_pthread.c-make-get_main_stack-portable-on-lin.patch'; \
66+
echo '3ab628a51d92fdf0d2b5835e93564857aea73e0c1de00313864a94a6255cb645 *thread-stack-fix.patch' | sha256sum --check --strict; \
67+
patch -p1 -i thread-stack-fix.patch; \
68+
rm thread-stack-fix.patch; \
6769
\
6870
# hack in "ENABLE_PATH_CHECK" disabling to suppress:
6971
# warning: Insecure world writable dir
70-
&& { \
72+
{ \
7173
echo '#define ENABLE_PATH_CHECK 0'; \
7274
echo; \
7375
cat file.c; \
74-
} > file.c.new \
75-
&& mv file.c.new file.c \
76+
} > file.c.new; \
77+
mv file.c.new file.c; \
7678
\
77-
&& autoconf \
78-
&& gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
79+
autoconf; \
80+
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
7981
# the configure script does not detect isnan/isinf as macros
80-
&& export ac_cv_func_isnan=yes ac_cv_func_isinf=yes \
81-
&& ./configure \
82+
export ac_cv_func_isnan=yes ac_cv_func_isinf=yes; \
83+
./configure \
8284
--build="$gnuArch" \
8385
--disable-install-doc \
8486
--enable-shared \
85-
&& make -j "$(nproc)" \
86-
&& make install \
87+
; \
88+
make -j "$(nproc)"; \
89+
make install; \
8790
\
88-
&& runDeps="$( \
91+
runDeps="$( \
8992
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \
9093
| tr ',' '\n' \
9194
| sort -u \
9295
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
93-
)" \
94-
&& apk add --no-network --virtual .ruby-rundeps $runDeps \
96+
)"; \
97+
apk add --no-network --virtual .ruby-rundeps \
98+
$runDeps \
9599
bzip2 \
96100
ca-certificates \
97101
libffi-dev \
98102
procps \
99103
yaml-dev \
100104
zlib-dev \
101-
&& apk del --no-network .ruby-builddeps \
102-
&& cd / \
103-
&& rm -r /usr/src/ruby \
105+
; \
106+
apk del --no-network .ruby-builddeps; \
107+
\
108+
cd /; \
109+
rm -r /usr/src/ruby; \
104110
# make sure bundled "rubygems" is older than RUBYGEMS_VERSION (https://github.com/docker-library/ruby/issues/246)
105-
&& ruby -e 'exit(Gem::Version.create(ENV["RUBYGEMS_VERSION"]) > Gem::Version.create(Gem::VERSION))' \
106-
&& gem update --system "$RUBYGEMS_VERSION" && rm -r /root/.gem/ \
111+
ruby -e 'exit(Gem::Version.create(ENV["RUBYGEMS_VERSION"]) > Gem::Version.create(Gem::VERSION))'; \
112+
gem update --system "$RUBYGEMS_VERSION" && rm -r /root/.gem/; \
107113
# rough smoke test
108-
&& ruby --version && gem --version && bundle --version
114+
ruby --version; \
115+
gem --version; \
116+
bundle --version
109117

110118
# install things globally, for great justice
111119
# and don't create ".bundle" in all our apps

2.4/jessie/Dockerfile

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
FROM buildpack-deps:jessie
22

33
# skip installing gem documentation
4-
RUN mkdir -p /usr/local/etc \
5-
&& { \
4+
RUN set -eux; \
5+
mkdir -p /usr/local/etc; \
6+
{ \
67
echo 'install: --no-document'; \
78
echo 'update: --no-document'; \
89
} >> /usr/local/etc/gemrc
@@ -14,53 +15,67 @@ ENV RUBYGEMS_VERSION 3.0.3
1415

1516
# some of ruby's build scripts are written in ruby
1617
# we purge system ruby later to make sure our final image uses what we just built
17-
RUN set -ex \
18+
RUN set -eux; \
1819
\
19-
&& buildDeps=' \
20+
savedAptMark="$(apt-mark showmanual)"; \
21+
apt-get update; \
22+
apt-get install -y --no-install-recommends \
2023
bison \
2124
dpkg-dev \
2225
libgdbm-dev \
2326
ruby \
24-
' \
25-
&& apt-get update \
26-
&& apt-get install -y --no-install-recommends $buildDeps \
27-
&& rm -rf /var/lib/apt/lists/* \
27+
; \
28+
rm -rf /var/lib/apt/lists/*; \
2829
\
29-
&& wget -O ruby.tar.xz "https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz" \
30-
&& echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz" | sha256sum -c - \
30+
wget -O ruby.tar.xz "https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz"; \
31+
echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz" | sha256sum --check --strict; \
3132
\
32-
&& mkdir -p /usr/src/ruby \
33-
&& tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1 \
34-
&& rm ruby.tar.xz \
33+
mkdir -p /usr/src/ruby; \
34+
tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1; \
35+
rm ruby.tar.xz; \
3536
\
36-
&& cd /usr/src/ruby \
37+
cd /usr/src/ruby; \
3738
\
3839
# hack in "ENABLE_PATH_CHECK" disabling to suppress:
3940
# warning: Insecure world writable dir
40-
&& { \
41+
{ \
4142
echo '#define ENABLE_PATH_CHECK 0'; \
4243
echo; \
4344
cat file.c; \
44-
} > file.c.new \
45-
&& mv file.c.new file.c \
45+
} > file.c.new; \
46+
mv file.c.new file.c; \
4647
\
47-
&& autoconf \
48-
&& gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
49-
&& ./configure \
48+
autoconf; \
49+
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
50+
./configure \
5051
--build="$gnuArch" \
5152
--disable-install-doc \
5253
--enable-shared \
53-
&& make -j "$(nproc)" \
54-
&& make install \
54+
; \
55+
make -j "$(nproc)"; \
56+
make install; \
5557
\
56-
&& apt-get purge -y --auto-remove $buildDeps \
57-
&& cd / \
58-
&& rm -r /usr/src/ruby \
58+
apt-mark auto '.*' > /dev/null; \
59+
apt-mark manual $savedAptMark > /dev/null; \
60+
find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \
61+
| awk '/=>/ { print $(NF-1) }' \
62+
| sort -u \
63+
| xargs -r dpkg-query --search \
64+
| cut -d: -f1 \
65+
| sort -u \
66+
| xargs -r apt-mark manual \
67+
; \
68+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
69+
\
70+
cd /; \
71+
rm -r /usr/src/ruby; \
5972
# make sure bundled "rubygems" is older than RUBYGEMS_VERSION (https://github.com/docker-library/ruby/issues/246)
60-
&& ruby -e 'exit(Gem::Version.create(ENV["RUBYGEMS_VERSION"]) > Gem::Version.create(Gem::VERSION))' \
61-
&& gem update --system "$RUBYGEMS_VERSION" && rm -r /root/.gem/ \
73+
ruby -e 'exit(Gem::Version.create(ENV["RUBYGEMS_VERSION"]) > Gem::Version.create(Gem::VERSION))'; \
74+
gem update --system "$RUBYGEMS_VERSION" && rm -r /root/.gem/; \
6275
# rough smoke test
63-
&& ruby --version && gem --version && bundle --version
76+
ruby --version; \
77+
gem --version; \
78+
bundle --version
6479

6580
# install things globally, for great justice
6681
# and don't create ".bundle" in all our apps

0 commit comments

Comments
 (0)