aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/rake-compiler-dock/Dockerfile
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rake-compiler-dock/Dockerfile')
-rw-r--r--third_party/rake-compiler-dock/Dockerfile109
1 files changed, 109 insertions, 0 deletions
diff --git a/third_party/rake-compiler-dock/Dockerfile b/third_party/rake-compiler-dock/Dockerfile
new file mode 100644
index 0000000000..11a6bd7796
--- /dev/null
+++ b/third_party/rake-compiler-dock/Dockerfile
@@ -0,0 +1,109 @@
+FROM ubuntu:14.04
+
+RUN apt-get -y update && \
+ apt-get install -y curl git-core mingw-w64 xz-utils build-essential wget unzip
+
+RUN mkdir -p /opt/mingw && \
+ curl -SL http://downloads.sourceforge.net/mingw-w64/i686-w64-mingw32-gcc-4.7.2-release-linux64_rubenvb.tar.xz | \
+ tar -xJC /opt/mingw && \
+ echo "export PATH=\$PATH:/opt/mingw/mingw32/bin" >> /etc/rubybashrc
+
+RUN mkdir -p /opt/mingw && \
+ curl -SL http://downloads.sourceforge.net/mingw-w64/x86_64-w64-mingw32-gcc-4.7.2-release-linux64_rubenvb.tar.xz | \
+ tar -xJC /opt/mingw && \
+ echo "export PATH=\$PATH:/opt/mingw/mingw64/bin" >> /etc/rubybashrc
+
+# Add "rvm" as system group, to avoid conflicts with host GIDs typically starting with 1000
+RUN groupadd -r rvm && useradd -r -g rvm -G sudo -p "" --create-home rvm && \
+ echo "source /etc/profile.d/rvm.sh" >> /etc/rubybashrc
+USER rvm
+
+# install rvm, RVM 1.26.0+ has signed releases, source rvm for usage outside of package scripts
+RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3 && \
+ (curl -L http://get.rvm.io | sudo bash -s stable) && \
+ bash -c " \
+ source /etc/rubybashrc && \
+ rvmsudo rvm cleanup all "
+
+# Import patch files for ruby and gems
+COPY build/patches /home/rvm/patches/
+ENV BASH_ENV /etc/rubybashrc
+
+# install rubies and fix permissions on
+RUN bash -c " \
+ export CFLAGS='-s -O3 -fno-fast-math -fPIC' && \
+ for v in 2.3.0 ; do \
+ rvm install \$v --patch \$(echo ~/patches/ruby-\$v/* | tr ' ' ','); \
+ done && \
+ rvm cleanup all && \
+ find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "
+
+# Install rake-compiler and typical gems in all Rubies
+# do not generate documentation for gems
+RUN echo "gem: --no-ri --no-rdoc" >> ~/.gemrc && \
+ bash -c " \
+ rvm all do gem install bundler rake-compiler hoe mini_portile rubygems-tasks json && \
+ rvm 2.3.0 do gem install mini_portile2 && \
+ find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "
+
+# Install rake-compiler's cross rubies in global dir instead of /root
+RUN sudo mkdir -p /usr/local/rake-compiler && \
+ sudo chown rvm.rvm /usr/local/rake-compiler && \
+ ln -s /usr/local/rake-compiler ~/.rake-compiler
+
+# Patch rake-compiler to avoid build of ruby extensions
+RUN cd /usr/local/rvm/gems/ruby-2.3.0/gems/rake-compiler-0.9.5 && patch -p1 < /home/rvm/patches/rake-compiler-0.9.5/without-exts.diff ; \
+ true
+
+RUN bash -c "rvm use 2.3.0 --default && \
+ export MAKE=\"make -j`nproc`\" CFLAGS='-s -O1 -fno-omit-frame-pointer -fno-fast-math' && \
+ rake-compiler cross-ruby VERSION=2.3.0 HOST=i686-w64-mingw32 && \
+ rake-compiler cross-ruby VERSION=2.3.0 HOST=x86_64-w64-mingw32 && \
+ rake-compiler cross-ruby VERSION=2.2.2 HOST=i686-w64-mingw32 && \
+ rake-compiler cross-ruby VERSION=2.2.2 HOST=x86_64-w64-mingw32 && \
+ rake-compiler cross-ruby VERSION=2.1.6 HOST=i686-w64-mingw32 && \
+ rake-compiler cross-ruby VERSION=2.1.6 HOST=x86_64-w64-mingw32 && \
+ rake-compiler cross-ruby VERSION=2.0.0-p645 HOST=i686-w64-mingw32 && \
+ rake-compiler cross-ruby VERSION=2.0.0-p645 HOST=x86_64-w64-mingw32 && \
+ rm -rf ~/.rake-compiler/builds ~/.rake-compiler/sources && \
+ find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "
+
+RUN bash -c " \
+ rvm alias create 2.3 2.3.0 "
+
+USER root
+
+# Fix paths in rake-compiler/config.yml and add rvm and mingw-tools to the global bashrc
+RUN sed -i -- "s:/root/.rake-compiler:/usr/local/rake-compiler:g" /usr/local/rake-compiler/config.yml && \
+ echo "source /etc/profile.d/rvm.sh" >> /etc/bash.bashrc && \
+ echo "export PATH=\$PATH:/opt/mingw/mingw32/bin" >> /etc/bash.bashrc && \
+ echo "export PATH=\$PATH:/opt/mingw/mingw64/bin" >> /etc/bash.bashrc
+
+# Install wrappers for strip commands as a workaround for "Protocol error" in boot2docker.
+COPY build/strip_wrapper /root/
+RUN mv /opt/mingw/mingw32/bin/i686-w64-mingw32-strip /opt/mingw/mingw32/bin/i686-w64-mingw32-strip.bin && \
+ mv /opt/mingw/mingw64/bin/x86_64-w64-mingw32-strip /opt/mingw/mingw64/bin/x86_64-w64-mingw32-strip.bin && \
+ mv /usr/bin/i686-w64-mingw32-strip /usr/bin/i686-w64-mingw32-strip.bin && \
+ mv /usr/bin/x86_64-w64-mingw32-strip /usr/bin/x86_64-w64-mingw32-strip.bin && \
+ ln /root/strip_wrapper /opt/mingw/mingw32/bin/i686-w64-mingw32-strip && \
+ ln /root/strip_wrapper /opt/mingw/mingw64/bin/x86_64-w64-mingw32-strip && \
+ ln /root/strip_wrapper /usr/bin/i686-w64-mingw32-strip && \
+ ln /root/strip_wrapper /usr/bin/x86_64-w64-mingw32-strip
+
+RUN find / -name rbconfig.rb | while read f ; do sed -i 's/0x0501/0x0600/' $f ; done
+RUN find / -name win32.h | while read f ; do sed -i 's/gettimeofday/rb_gettimeofday/' $f ; done
+RUN sed -i 's/defined.__MINGW64__.$/1/' /usr/local/rake-compiler/ruby/i686-w64-mingw32/ruby-2.0.0-p645/include/ruby-2.0.0/ruby/win32.h
+
+# Install SIGINT forwarder
+COPY build/sigfw.c /root/
+RUN gcc $HOME/sigfw.c -o /usr/local/bin/sigfw
+
+# Install user mapper
+COPY build/runas /usr/local/bin/
+
+# Install sudoers configuration
+COPY build/sudoers /etc/sudoers.d/rake-compiler-dock
+
+ENV RUBY_CC_VERSION 2.3.0:2.2.2:2.1.6:2.0.0
+
+CMD bash