-
Notifications
You must be signed in to change notification settings - Fork 336
/
Copy pathDockerfile
160 lines (152 loc) · 4.54 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#
# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh"
#
# PLEASE DO NOT EDIT IT DIRECTLY.
#
FROM alpine:3.21
RUN set -eux; \
apk add --no-cache \
bzip2 \
ca-certificates \
gmp-dev \
libffi-dev \
procps \
yaml-dev \
zlib-dev \
;
# skip installing gem documentation with `gem install`/`gem update`
RUN set -eux; \
mkdir -p /usr/local/etc; \
echo 'gem: --no-document' >> /usr/local/etc/gemrc
ENV LANG C.UTF-8
# https://www.ruby-lang.org/en/news/2024/12/25/ruby-3-4-1-released/
ENV RUBY_VERSION 3.4.1
ENV RUBY_DOWNLOAD_URL https://cache.ruby-lang.org/pub/ruby/3.4/ruby-3.4.1.tar.xz
ENV RUBY_DOWNLOAD_SHA256 018d59ffb52be3c0a6d847e22d3fd7a2c52d0ddfee249d3517a0c8c6dbfa70af
# some of ruby's build scripts are written in ruby
# we purge system ruby later to make sure our final image uses what we just built
RUN set -eux; \
\
apk add --no-cache --virtual .ruby-builddeps \
autoconf \
bzip2 \
bzip2-dev \
ca-certificates \
coreutils \
dpkg-dev dpkg \
g++ \
gcc \
gdbm-dev \
glib-dev \
libc-dev \
libffi-dev \
libxml2-dev \
libxslt-dev \
linux-headers \
make \
ncurses-dev \
openssl \
openssl-dev \
patch \
procps \
ruby \
tar \
xz \
yaml-dev \
zlib-dev \
; \
\
rustArch=; \
apkArch="$(apk --print-arch)"; \
case "$apkArch" in \
'x86_64') rustArch='x86_64-unknown-linux-musl'; rustupUrl='https://static.rust-lang.org/rustup/archive/1.26.0/x86_64-unknown-linux-musl/rustup-init'; rustupSha256='7aa9e2a380a9958fc1fc426a3323209b2c86181c6816640979580f62ff7d48d4' ;; \
'aarch64') rustArch='aarch64-unknown-linux-musl'; rustupUrl='https://static.rust-lang.org/rustup/archive/1.26.0/aarch64-unknown-linux-musl/rustup-init'; rustupSha256='b1962dfc18e1fd47d01341e6897cace67cddfabf547ef394e8883939bd6e002e' ;; \
esac; \
\
if [ -n "$rustArch" ]; then \
mkdir -p /tmp/rust; \
\
wget -O /tmp/rust/rustup-init "$rustupUrl"; \
echo "$rustupSha256 */tmp/rust/rustup-init" | sha256sum --check --strict; \
chmod +x /tmp/rust/rustup-init; \
\
export RUSTUP_HOME='/tmp/rust/rustup' CARGO_HOME='/tmp/rust/cargo'; \
export PATH="$CARGO_HOME/bin:$PATH"; \
/tmp/rust/rustup-init -y --no-modify-path --profile minimal --default-toolchain '1.74.1' --default-host "$rustArch"; \
\
rustc --version; \
cargo --version; \
fi; \
\
wget -O ruby.tar.xz "$RUBY_DOWNLOAD_URL"; \
echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz" | sha256sum --check --strict; \
\
mkdir -p /usr/src/ruby; \
tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1; \
rm ruby.tar.xz; \
\
cd /usr/src/ruby; \
\
# https://github.com/docker-library/ruby/issues/196
# https://bugs.ruby-lang.org/issues/14387#note-13 (patch source)
# 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)
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'; \
echo '3ab628a51d92fdf0d2b5835e93564857aea73e0c1de00313864a94a6255cb645 *thread-stack-fix.patch' | sha256sum --check --strict; \
patch -p1 -i thread-stack-fix.patch; \
rm thread-stack-fix.patch; \
\
# hack in "ENABLE_PATH_CHECK" disabling to suppress:
# warning: Insecure world writable dir
{ \
echo '#define ENABLE_PATH_CHECK 0'; \
echo; \
cat file.c; \
} > file.c.new; \
mv file.c.new file.c; \
\
autoconf; \
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
./configure \
--build="$gnuArch" \
--disable-install-doc \
--enable-shared \
${rustArch:+--enable-yjit} \
; \
make -j "$(nproc)"; \
make install; \
\
rm -rf /tmp/rust; \
runDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \
| tr ',' '\n' \
| sort -u \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
)"; \
apk add --no-network --virtual .ruby-rundeps $runDeps; \
apk del --no-network .ruby-builddeps; \
\
cd /; \
rm -r /usr/src/ruby; \
# verify we have no "ruby" packages installed
if \
apk --no-network list --installed \
| grep -v '^[.]ruby-rundeps' \
| grep -i ruby \
; then \
exit 1; \
fi; \
[ "$(command -v ruby)" = '/usr/local/bin/ruby' ]; \
# rough smoke test
ruby --version; \
gem --version; \
bundle --version
# don't create ".bundle" in all our apps
ENV GEM_HOME /usr/local/bundle
ENV BUNDLE_SILENCE_ROOT_WARNING=1 \
BUNDLE_APP_CONFIG="$GEM_HOME"
ENV PATH $GEM_HOME/bin:$PATH
RUN set -eux; \
mkdir "$GEM_HOME"; \
# adjust permissions of GEM_HOME for running "gem install" as an arbitrary user
chmod 1777 "$GEM_HOME"
CMD [ "irb" ]