@@ -50,9 +50,17 @@ RUN set -eux; \
5050 } >> /usr/local/etc/gemrc
5151
5252ENV LANG C.UTF-8
53+
54+ # https://www.ruby-lang.org/{{ .post | ltrimstr("/") }}
55+ {{ if env.version == "3.0" then ( -}}
5356ENV RUBY_MAJOR {{ env.version }}
5457ENV RUBY_VERSION {{ .version }}
55- ENV RUBY_DOWNLOAD_SHA256 {{ .sha256 }}
58+ ENV RUBY_DOWNLOAD_SHA256 {{ .sha256.xz }}
59+ {{ ) else ( -}}
60+ ENV RUBY_VERSION {{ .version }}
61+ ENV RUBY_DOWNLOAD_URL {{ .url.xz }}
62+ ENV RUBY_DOWNLOAD_SHA256 {{ .sha256.xz }}
63+ {{ ) end -}}
5664
5765ENV jemalloc_pkgver 3.6.0
5866ENV jemalloc_sha256 e16c2159dd3c81ca2dc3b5c9ef0d43e1f2f45b04548f42db12e7c12d7bdf84fe
@@ -65,7 +73,10 @@ RUN set -eux; \
6573# readline-dev vs libedit-dev: https://bugs.ruby-lang.org/issues/11869 and https://github.com/docker-library/ruby/issues/75
6674 apk add --no-cache --virtual .ruby-builddeps \
6775 autoconf \
76+ {{ if env.version | rtrimstr("-rc") | IN("3.0", "3.1", "3.2") then ( -}}
77+ {{ # https://github.com/docker-library/ruby/pull/438 -}}
6878 bison \
79+ {{ ) else "" end -}}
6980 bzip2 \
7081 bzip2-dev \
7182 ca-certificates \
@@ -86,7 +97,7 @@ RUN set -eux; \
8697 openssl-dev \
8798 patch \
8899 procps \
89- {{ if [ " 3.0", "3.1", "3.2" ] | index(env.version | rtrimstr("-rc") ) then ( -}}
100+ {{ if env.version | rtrimstr("-rc") | IN(" 3.0", "3.1", "3.2") then ( -}}
90101 readline-dev \
91102{{ ) else "" end -}}
92103 ruby \
@@ -99,7 +110,10 @@ RUN set -eux; \
99110 savedAptMark="$(apt-mark showmanual)"; \
100111 apt-get update; \
101112 apt-get install -y --no-install-recommends \
113+ {{ if env.version | rtrimstr("-rc") | IN("3.0", "3.1", "3.2") then ( -}}
114+ {{ # https://github.com/docker-library/ruby/pull/438 -}}
102115 bison \
116+ {{ ) else "" end -}}
103117 dpkg-dev \
104118 libgdbm-dev \
105119 ruby \
@@ -111,7 +125,7 @@ RUN set -eux; \
111125 libgdbm-compat-dev \
112126 libglib2.0-dev \
113127 libncurses-dev \
114- {{ if [ " 3.0", "3.1", "3.2" ] | index(env.version | rtrimstr("-rc") ) then ( -}}
128+ {{ if env.version | rtrimstr("-rc") | IN(" 3.0", "3.1", "3.2") then ( -}}
115129 libreadline-dev \
116130{{ ) else "" end -}}
117131 libxml2-dev \
@@ -204,7 +218,12 @@ RUN set -eux; \
204218 strip --strip-debug "/usr/lib/libjemalloc.so" && rm -rf "/usr/lib/pkgconfig"; \
205219 cd / && rm -rf /jemalloc-stable; \
206220 \
221+ {{ if env.version == "3.0" then ( -}}
222+ {{ if .url.xz != "https://cache.ruby-lang.org/pub/ruby/\(env.version | rtrimstr("-rc"))/ruby-\(.version).tar.xz" then error("url for \(.version) is not as expected!") else "" end -}}
207223 wget -O ruby.tar.xz "https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz"; \
224+ {{ ) else ( -}}
225+ wget -O ruby.tar.xz "$RUBY_DOWNLOAD_URL"; \
226+ {{ ) end -}}
208227 echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz" | sha256sum --check --strict; \
209228 \
210229 mkdir -p /usr/src/ruby; \
@@ -267,19 +286,19 @@ RUN set -eux; \
267286 esac; \
268287{{ ) else "" end -}}
269288 gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
270- {{ if ( [ "3.1" ] | index(env.version) ) then ( -}}
289+ {{ if env.version | rtrimstr("-rc") | IN("3.1" ) then ( -}}
271290 # add ruby 3.1 jemalloc patch
272291 wget -O 'ruby_31_jemalloc.patch' 'https://raw.githubusercontent.com/fullstaq-ruby/server-edition/main/resources/ruby_31_jemalloc.patch'; \
273292 patch -p1 -ti ruby_31_jemalloc.patch; \
274293 rm ruby_31_jemalloc.patch; \
275294{{ ) else "" end -}}
276- {{ if ( [ "3.3-rc" ] | index(env.version) ) then ( -}}
295+ {{ if env.version | IN( "3.3-rc") then ( -}}
277296 # add ruby 3.3-rc(preview3) jemalloc patch
278297 wget -O 'ruby_33_preview3_jemalloc.patch' 'https://gist.githubusercontent.com/jitingcn/16c492b36575112febe1c82d3e45fe2a/raw/751ad215e3e2f12a3a00a55f649355826aab4ce4/ruby_33_preview3_jemalloc.patch'; \
279298 patch -p1 -ti ruby_33_preview3_jemalloc.patch; \
280299 rm ruby_33_preview3_jemalloc.patch; \
281300{{ ) else "" end -}}
282- {{ if ( [ "3.2" ] | index(env.version) ) then ( -}}
301+ {{ if env.version | rtrimstr("-rc") | IN("3.2" ) then ( -}}
283302 # add ruby 3.2 jemalloc patch
284303 wget -O 'ruby_32_jemalloc.patch' 'https://gist.githubusercontent.com/jitingcn/4a518dbd1d0112bdb5789a65e6456033/raw/1e378904e1f3766f4faa1c5cb87e045a9bd1f6f2/ruby_32_jemalloc.patch'; \
285304 patch -p1 -ti ruby_32_jemalloc.patch; \
@@ -315,7 +334,7 @@ RUN set -eux; \
315334 apt-mark auto '.*' > /dev/null; \
316335 apt-mark manual $savedAptMark > /dev/null; \
317336 find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \
318- | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \
337+ | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \
319338 | sort -u \
320339 | xargs -r dpkg-query --search \
321340 | cut -d: -f1 \
@@ -360,7 +379,9 @@ ENV GEM_HOME /usr/local/bundle
360379ENV BUNDLE_SILENCE_ROOT_WARNING=1 \
361380 BUNDLE_APP_CONFIG="$GEM_HOME"
362381ENV PATH $GEM_HOME/bin:$PATH
363- # adjust permissions of a few directories for running "gem install" as an arbitrary user
364- RUN mkdir -p "$GEM_HOME" && chmod 1777 "$GEM_HOME"
382+ RUN set -eux; \
383+ mkdir "$GEM_HOME"; \
384+ # adjust permissions of GEM_HOME for running "gem install" as an arbitrary user
385+ chmod 1777 "$GEM_HOME"
365386
366387CMD [ "irb" ]
0 commit comments