From bd293c3cb496e51c3a6aedaaf6f515f9c99977de Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 8 Apr 2015 15:06:53 +1000 Subject: [PATCH] create an image for quickly switching ruby versions --- image/discourse_fast_switch/Dockerfile | 16 +++++++++++ image/discourse_fast_switch/create_switch.rb | 30 ++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 image/discourse_fast_switch/Dockerfile create mode 100644 image/discourse_fast_switch/create_switch.rb diff --git a/image/discourse_fast_switch/Dockerfile b/image/discourse_fast_switch/Dockerfile new file mode 100644 index 0000000..d951243 --- /dev/null +++ b/image/discourse_fast_switch/Dockerfile @@ -0,0 +1,16 @@ +# Allow to easily switch Ruby version in images that derive off this + +FROM samsaffron/discourse:1.0.10 + +MAINTAINER Sam Saffron "https://twitter.com/samsaffron" + +RUN apt-get -y install ruby bison autoconf &&\ + echo install_package "openssl-1.0.1l" "https://www.openssl.org/source/openssl-1.0.1l.tar.gz#b2cf4d48fe5d49f240c61c9e624193a6f232b5ed0baf010681e725963c40d1d4" mac_openssl --if has_broken_mac_openssl > /src/2.2.2-github &&\ + echo install_package "ruby-2.2.2-github" "https://github.com/SamSaffron/ruby/archive/2.2.2-github.tar.gz#407654b4fe9dd61ca7e26d8d7e4c8631" autoconf ldflags_dirs standard verify_openssl >> /src/2.2.2-github &&\ + ruby-build /src/2.2.2-github /usr/ruby_22 &&\ + apt-get -y remove ruby + +RUN cd / && rm -rf /src/ruby-build && ruby-build 2.0.0-p643 /usr/ruby_20 + +ADD create_switch.rb /src/create_switch.rb +RUN ruby /src/create_switch.rb diff --git a/image/discourse_fast_switch/create_switch.rb b/image/discourse_fast_switch/create_switch.rb new file mode 100644 index 0000000..ecb6e06 --- /dev/null +++ b/image/discourse_fast_switch/create_switch.rb @@ -0,0 +1,30 @@ +require 'fileutils' + +puts "-"*100,"creating switch","-"*100 + +Dir.glob('/usr/ruby_20/*/**').each do |file| + file = file.gsub('/usr/ruby_20/', '/usr/local/') + FileUtils.rm(file) if File.exists?(file) && !File.directory?(file) +end + +system("cd /var/www/discourse && git pull") + +['22','20'].each do |v| + + bin = "/usr/local/bin/use_#{v}" + +File.write(bin, <