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