@@ -10,9 +10,12 @@ manylinux = !!(image =~ /manylinux/)
10
10
%>
11
11
FROM <%= image %>
12
12
13
+ ##
14
+ ## RVM and native rubies
15
+ ##
16
+ # Install packages which rvm will require
13
17
<% if manylinux %>
14
- # install packages which rvm will require
15
- RUN yum install -y autoconf gcc-c++ libtool readline-devel sqlite-devel ruby openssl-devel xz cmake sudo less libffi-devel git wget
18
+ RUN yum install -y sudo ruby less git wget curl autoconf libtool cmake gcc-c++ xz readline-devel sqlite-devel openssl-devel libffi-devel libyaml-devel
16
19
17
20
# Prepare sudo and delete sudo as alias to gosu
18
21
RUN rm -f /usr/local/bin/sudo && \
@@ -21,7 +24,7 @@ RUN rm -f /usr/local/bin/sudo && \
21
24
<% else %>
22
25
ENV DEBIAN_FRONTEND noninteractive
23
26
RUN apt-get -y update && \
24
- apt-get install -y curl git-core xz-utils build-essential zlib1g-dev libreadline-dev libssl-dev wget unzip sudo gnupg2 dirmngr cmake pkg-config autoconf && \
27
+ apt-get install -y sudo wget autoconf cmake curl git-core pkg-config build-essential xz-utils unzip gnupg2 dirmngr zlib1g-dev libreadline-dev libsqlite0-dev libssl-dev libyaml-dev libffi-dev && \
25
28
rm -rf /var/lib/apt/lists/*
26
29
<% end %>
27
30
@@ -44,38 +47,31 @@ RUN mkdir ~/.gnupg && \
44
47
RUN gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB && \
45
48
(curl -L http://get.rvm.io | sudo bash) && \
46
49
bash -c " \
47
- source /etc/rubybashrc && \
48
- rvm autolibs disable && \
49
- rvmsudo rvm cleanup all "
50
+ source /etc/rubybashrc && \
51
+ rvm autolibs disable && \
52
+ rvmsudo rvm cleanup all \
53
+ "
50
54
51
- # Import patch files for ruby and gems
55
+ # Install native rubies and fix permissions
52
56
COPY build/patches /home/rvm/patches/
53
-
54
- # install rubies and fix permissions on
55
57
ENV RVM_RUBIES 2.5.9 3.1.0
56
58
RUN bash -c " \
57
- export CFLAGS='-s -O3 -fno-fast-math -fPIC' && \
58
- for v in ${RVM_RUBIES} ; do \
59
+ export CFLAGS='-s -O3 -fno-fast-math -fPIC' && \
60
+ for v in ${RVM_RUBIES} ; do \
59
61
rvm install \$v --patch \$(echo ~/patches/ruby-\$v/* | tr ' ' ','); \
60
- done && \
61
- rvm cleanup all && \
62
- find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "
63
-
64
- # Install rake-compiler and typical gems in all Rubies
65
- # do not generate documentation for gems
66
- # TODO: stop pinning rubygems to 3.3.20 once https://github.com/rake-compiler/rake-compiler/pull/209 is merged
67
- RUN echo "gem: --no-ri --no-rdoc" > > ~/.gemrc && \
68
- bash -c " \
69
- rvm all do gem update --system=3.3.20 --no-document && \
70
- rvm all do gem install --no-document bundler 'bundler:~> 1.16' 'rake-compiler:1.1.6' hoe mini_portile rubygems-tasks mini_portile2 && \
71
- find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "
72
-
73
- # Install rake-compiler's cross rubies in global dir instead of /root
74
- RUN sudo mkdir -p /usr/local/rake-compiler && \
75
- sudo chown rvm.rvm /usr/local/rake-compiler && \
76
- ln -s /usr/local/rake-compiler ~/.rake-compiler
62
+ done && \
63
+ rvm cleanup all \
64
+ "
77
65
78
- # Add cross compilers for Windows and Linux
66
+ RUN bash -c " \
67
+ rvm all do gem update --system --no-document && \
68
+ rvm all do gem update --no-document && \
69
+ rvm all do gem install bundler --no-document \
70
+ "
71
+
72
+ ##
73
+ ## Cross compilers
74
+ ##
79
75
USER root
80
76
81
77
<% if platform =~/x64-mingw-ucrt/ %>
@@ -100,77 +96,46 @@ if platform=~/x64-mingw32/ %> gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 <% end
100
96
rm -rf /var/lib/apt/lists/*
101
97
<% end %>
102
98
103
- RUN bash -c " \
104
- rvm alias create default 3.1.0 && \
105
- rvm use default "
106
-
107
99
<% if manylinux %>
108
100
# Create dev tools x86-linux-*
109
101
COPY build/mk_i686.rb /root/
110
- RUN bash -c " \
111
- ruby /root/mk_i686.rb "
102
+ RUN /root/mk_i686.rb
112
103
<% end %>
113
104
114
105
<% if platform =~/darwin/ %>
115
- RUN git clone -q --depth=1 https://github.com/tpoechtrager/osxcross.git /opt/osxcross && rm -rf /opt/osxcross/.git && \
116
- cd /opt/osxcross/tarballs && \
117
- curl -L -o MacOSX11.1.sdk.tar.xz https://github.com/larskanis/MacOSX-SDKs/releases/download/11.1/MacOSX11.1.sdk.tar.xz && \
118
- tar -xf MacOSX11.1.sdk.tar.xz -C . && \
119
- cp -rf /usr/lib/llvm-10/include/c++ MacOSX11.1.sdk/usr/include/c++ && \
120
- cp -rf /usr/include/"$(uname -m)"-linux-gnu/c++/9/bits/ MacOSX11.1.sdk/usr/include/c++/v1/bits && \
121
- tar -cJf MacOSX11.1.sdk.tar.xz MacOSX11.1.sdk && \
122
- cd /opt/osxcross && \
123
- UNATTENDED=1 SDK_VERSION=11.1 OSX_VERSION_MIN=10.13 USE_CLANG_AS=1 ./build.sh && \
124
- ln -s /usr/bin/llvm-config-10 /usr/bin/llvm-config && \
125
- ENABLE_COMPILER_RT_INSTALL=1 SDK_VERSION=11.1 ./build_compiler_rt.sh && \
126
- rm -rf *~ build tarballs/*
127
-
128
- RUN echo "export PATH=/opt/osxcross/target/bin:\$PATH" > > /etc/rubybashrc && \
129
- echo "export MACOSX_DEPLOYMENT_TARGET=10.13" > > /etc/rubybashrc && \
130
- echo "export OSXCROSS_MP_INC=1" > > /etc/rubybashrc
131
-
132
- # Add links to build tools without target version kind of:
133
- # arm64-apple-darwin-clang => arm64-apple-darwin20.1-clang
134
- RUN rm /opt/osxcross/target/bin/*-apple-darwin-* ; \
135
- find /opt/osxcross/target/bin/ -name '*-apple-darwin[0-9]*' | sort | while read f ; do d=`echo $f | sed s/darwin[0-9\.]*/darwin/`; echo $f '"$@"' | tee $d && chmod +x $d ; done
136
-
137
- # There's no objdump in osxcross but we can use llvm's
138
- RUN ln -s /usr/lib/llvm-10/bin/llvm-objdump /opt/osxcross/target/bin/x86_64-apple-darwin-objdump && \
139
- ln -s /usr/lib/llvm-10/bin/llvm-objdump /opt/osxcross/target/bin/aarch64-apple-darwin-objdump
140
-
106
+ COPY build/mk_osxcross.sh /home/rvm
107
+ RUN /home/rvm/mk_osxcross.sh
141
108
<% end %>
142
109
143
- # Patch rake-compiler to build and install static libraries for Linux rubies
110
+
111
+ ##
112
+ ## Cross-compile rubies
113
+ ##
144
114
USER rvm
115
+
116
+ RUN bash -c "rvm all do gem install --no-document rake-compiler:1.2.1"
117
+
118
+ # Install rake-compiler's cross rubies in global dir instead of /root
119
+ RUN sudo mkdir -p /usr/local/rake-compiler && \
120
+ sudo chown rvm.rvm /usr/local/rake-compiler && \
121
+ ln -s /usr/local/rake-compiler ~/.rake-compiler
122
+
123
+ # Patch rake-compiler to build and install static libraries for Linux rubies
145
124
COPY build/patches2 /home/rvm/patches/
146
125
RUN bash -c " \
147
- for v in ${RVM_RUBIES} ; do \
148
- cd /usr/local/rvm/gems/ruby-\$v/gems/rake-compiler-1.1.6 && \
149
- echo applying patches to ruby-\$v /home/rvm/patches/rake-compiler-1.1.6/*.patch && \
150
- ( git apply /home/rvm/patches/rake-compiler-1.1.6/*.patch || true ) \
151
- done "
152
-
153
- # Patch rubies for cross build
154
- #USER root
155
- #RUN bash -c " \
156
- # for v in 2.7.0 3.0.0 3.1.0 ; do \
157
- # curl -SL http://cache.ruby-lang.org/pub/ruby/\${v:0:3}/ruby-\$v.tar.xz | tar -xJC /root/ && \
158
- # cd /root/ruby-\$v && \
159
- # git apply /home/rvm/patches/ruby-\$v/*.patch && \
160
- # cd .. && \
161
- # mkdir -p /usr/local/rake-compiler/sources/ && \
162
- # tar cjf /usr/local/rake-compiler/sources/ruby-\$v.tar.bz2 ruby-\$v && \
163
- # chown rvm /usr/local/rake-compiler -R && \
164
- # rm -rf /root/ruby-\$v ; \
165
- # done "
166
- #USER rvm
126
+ for v in ${RVM_RUBIES} ; do \
127
+ cd /usr/local/rvm/gems/ruby-\$v/gems/rake-compiler-1.2.1 && \
128
+ echo applying patches to ruby-\$v /home/rvm/patches/rake-compiler-1.2.1/*.patch && \
129
+ ( git apply /home/rvm/patches/rake-compiler-1.2.1/*.patch || true ) \
130
+ done \
131
+ "
167
132
168
133
<%
169
134
axrubies = if platform =~ /x64-mingw-ucrt/
170
135
[
171
136
# Rubyinstaller-3.1.0+ is platform x64-mingw-ucrt
172
- [ " 3.2.0-rc1" , "3.1.0" , true ] ,
173
- [ "3.1.0" , "3.1.0" , true ] ,
137
+ # parallel=false because 3.2.0-rc1 has undefined references when using a high -j arg
138
+ [ "3.2.0-rc1:3. 1.0" , "3.1.0" , false ] ,
174
139
]
175
140
elsif platform =~ /x64-mingw32/
176
141
[
@@ -194,16 +159,16 @@ ENV XRUBIES <%= xrubies %>
194
159
# Build xruby versions in parallel
195
160
# Then cleanup all build artifacts
196
161
RUN bash -c " \
197
- rvm use <%= rvm %> && \
198
- export CPPFLAGS='<%= "-D__USE_MINGW_ANSI_STDIO=1" if platform =~/x64-mingw-ucrt/ %> ' && \
199
- export CFLAGS='-O1 -fno-omit-frame-pointer -fno-fast-math -fstack-protector-strong <%= strip %> ' && \
200
- export LDFLAGS='-pipe <%= strip %> ' && \
201
- <%= "export LIBS='-l:libssp.a' &&" if platform =~ /mingw/ %> \
202
- <%= "export CC=#{ target } -clang &&" if platform =~ /darwin/ %> \
203
- export MAKE='make V=1 <%= "-j`nproc`" if parallel %> ' && \
204
- rake-compiler cross-ruby VERSION=$XRUBIES HOST=<%= target %> && \
205
- rm -rf ~/.rake-compiler/builds ~/.rake-compiler/sources && \
206
- find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "
162
+ rvm use <%= rvm %> && \
163
+ export CPPFLAGS='<%= "-D__USE_MINGW_ANSI_STDIO=1" if platform =~/x64-mingw-ucrt/ %> ' && \
164
+ export CFLAGS='-O1 -fno-omit-frame-pointer -fno-fast-math -fstack-protector-strong <%= strip %> ' && \
165
+ export LDFLAGS='-pipe <%= strip %> ' && \
166
+ <%= "export LIBS='-l:libssp.a' &&" if platform =~ /mingw/ %> \
167
+ <%= "export CC=#{ target } -clang &&" if platform =~ /darwin/ %> \
168
+ export MAKE='make V=1 <%= "-j`nproc`" if parallel %> ' && \
169
+ rake-compiler cross-ruby VERSION=$XRUBIES HOST=<%= target %> && \
170
+ rm -rf ~/.rake-compiler/builds ~/.rake-compiler/sources \
171
+ "
207
172
<% end %>
208
173
209
174
<% if platform =~/linux/ %>
@@ -224,12 +189,14 @@ RUN find /usr/local/rake-compiler/ruby -name rbconfig.rb | while read f ; do sed
224
189
RUN find /usr/local/rake-compiler/ruby -name lib*-ruby*.dll.a | while read f ; do n=`echo $f | sed s /.dll//` ; mv $f $n ; done
225
190
<% end %>
226
191
192
+ ##
193
+ ## Final adjustments
194
+ ##
227
195
USER root
228
196
229
197
# Fix paths in rake-compiler/config.yml
230
198
RUN sed -i -- "s:/root/.rake-compiler:/usr/local/rake-compiler:g" /usr/local/rake-compiler/config.yml
231
199
232
-
233
200
<% if platform =~/mingw/ %>
234
201
# Install wrappers for strip commands as a workaround for "Protocol error" in boot2docker.
235
202
COPY build/strip_wrapper /root/
@@ -276,6 +243,12 @@ RUN echo "source /etc/profile.d/rcd-env.sh" >> /etc/rubybashrc
276
243
# Install sudoers configuration
277
244
COPY build/sudoers /etc/sudoers.d/rake-compiler-dock
278
245
246
+ RUN find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw
247
+ RUN bash -c " \
248
+ rvm alias create default 3.1.0 && \
249
+ rvm use default \
250
+ "
251
+
279
252
ENV RUBY_CC_VERSION 3.2.0:3.1.0:3.0.0:2.7.0:2.6.0:2.5.0:2.4.0
280
253
281
254
CMD bash
0 commit comments