khinester
khinester

Reputation: 3530

running ruby 1.8.7 in docker

i have inherited a very old app, that was built using ruby 1.8.7 with postgres and i am trying to create a docker image for this.

from this image https://hub.docker.com/r/hublogix/minimal-ruby/ i have the app code added to the image.

so now i am inside the image, i can see:

bash-4.3# ls
Capfile    REVISION   Rakefile   app        config     config.ru  db         doc        lib        public     script     test       tmp        vendor
bash-4.3#


bash-4.3# gem install rake
Fetching: rake-12.3.1.gem (100%)
ERROR:  Error installing rake:
        rake requires Ruby version >= 2.0.0.
bash-4.3#

config/environment.rb is like:

# Be sure to restart your server when you modify this file

# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.16' unless defined? RAILS_GEM_VERSION

APP_NAME = "App name"

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')

Rails::Initializer.run do |config|

  config.gem "inherited_resources",
    :source => "http://gemcutter.org",
    :version => "1.0.1"

  config.gem "has_scope",
    :lib    => "has_scope",
    :source => 'http://gemcutter.org',
    :version => "0.4.1"

  config.gem "haml"

  config.gem "will_paginate", 
    :lib    => "will_paginate",
    :source => "http://gemcutter.org"

  config.gem "searchlogic",
    :lib     => "searchlogic",
    :source  => "http://gemcutter.org",
    :version => "2.4.11"

  config.gem "paperclip",
    :lib     => "paperclip",
    :source  => "http://gemcutter.org",
    :version => "2.3.1.1"

  config.gem "clearance",
    :lib     => "clearance",
    :source  => "http://gemcutter.org",
    :version => "0.8.8"

  config.gem "rsl-stringex",
    :lib     => "stringex",
    :source  => "http://gems.github.com",
    :version => "1.0.3"

  config.gem 'formtastic',
    :lib     => "formtastic",
    :version => "0.9.7"

  config.gem "acts_as_audited",
    :lib     => "acts_as_audited",
    :version => "1.1.0"

  config.gem "prawn",
    :version => "0.8.4"

  config.gem "htmlentities",
    :version => "4.2.0"

  config.gem "emap_single_sign_on"

  config.gem "rmagick",
    :lib => "RMagick"

  config.load_paths += %W( #{Rails.root}/app/mailers #{Rails.root}/app/observers #{Rails.root}/app/sweepers )
  config.load_paths += %W( #{Rails.root}/app/presenters #{Rails.root}/app/reports)

  config.frameworks -= [ :active_resource ]

  # config.active_record.observers = :name

  config.time_zone = 'UTC'

end

GOOGLE_ANALYTICS_TRACKING_CODE = ""

and when i try to run it i get this error from the container:

/usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:900:in `report_activate_error': Could not find RubyGem rack (~> 1.1.0) (Gem::LoadError)
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `activate'
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:1276:in `gem'
        from /usr/src/vendor/rails/actionpack/lib/action_controller.rb:34
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
        from /usr/src/vendor/rails/activesupport/lib/active_support/dependencies.rb:182:in `require'
        from /usr/src/vendor/rails/activesupport/lib/active_support/dependencies.rb:547:in `new_constants_in'
        from /usr/src/vendor/rails/activesupport/lib/active_support/dependencies.rb:182:in `require'
        from /usr/src/vendor/rails/railties/lib/commands/server.rb:2
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
        from ./script/server:3

depandanices list:

actionmailer (2.3.17)
actionpack (2.3.17)
activerecord (2.3.17)
activeresource (2.3.17)
activesupport (2.3.17)
andre-geokit (1.2.5)
backup (3.0.25)
builder (3.2.2)
bundler (1.5.3)
excon (0.31.0)
fastercsv (1.5.5, 1.5.4)
formatador (0.2.4)
geocoder (1.1.9)
haml (4.0.5, 2.0.9)
json (1.8.1)
mislav-will_paginate (2.3.11)
multi_json (1.9.0)
mysql (2.9.1, 2.8.1)
newrelic_rpm (3.7.3.204)
nokogiri (1.4.2, 1.4.1)
open4 (1.3.3)
puma (2.8.1)
rack (1.1.6, 1.1.0)
rails (2.3.17)
rake (10.1.1)
rdoc (4.1.1)
RedCloth (4.2.9)
right_aws (3.1.0)
right_http_connection (1.4.0)
rmagick (2.13.3, 2.13.2)
rubyist-aasm (2.0.5)
stringex (1.2.0)
thor (0.15.4)
thoughtbot-paperclip (2.2.9.2)
tilt (2.0.0)

i have the vendor folder which has all the dependencies, but i am unclear as to what else i need to do in order to install the base system in docker?

any advice on how to get this app running in docker or get it to build?

Upvotes: 0

Views: 1653

Answers (1)

spickermann
spickermann

Reputation: 107077

When you install the rake gem manually with gem install rake then gem tries to install the latest version. But the latest version of rake doesn't support your old version of Ruby anymore. Instead, you need to pick a version that still works with Ruby 1.8.7

But that is only part of your problem. Your difficulty is that you need to install all the dependencies of your application without any information on what dependencies your application might have.

Since Ruby on Rails 3.0 bundler is used to manage dependencies. And I highly suggest that you start fixing your issue by adding bundler and a Gemfile to your application.

Remember, you have only very limited information about what dependencies your application might have. You know that it was build against Ruby 1.8.7 which was released mid-2008. Therefore, I guess that your application was built 2008–2010 (after 2010 the developer would likely have used Ruby 1.9.x).

The up-to-date versions of rake were ~> 0.8.3 at that time (see rake versions). Furthermore, I guess your application uses Ruby on Rails 2.x (see rails versions). In <3.0 Rails application, you can usually find the Rails version in config/environment.rb assigned to RAILS_GEM_VERSION. I assume it is 2.3.5. Create a Gemfile with this information in your application root:

source 'https://rubygems.org'

gem 'rails', '2.3.5'
gem 'rake', '~> 0.8.7'

Install these gems by running bundle install and try to open the rails console or to start the application server. This will very likely not work, and you will need to add more gems to the list of dependencies in your Gemfile.

I guess you will need to add these:

gem 'rack', '~> 0.9.0'
gem 'mysql', '2.8.1'

Look closely at error messages, if Ruby – for example – is complaining about a missing gem with the name foo then look on Rubygems what version of the foo gem was available around 2008-2010 and add gem 'foo', '<version number>' to your Gemfile and run bundle install again.

It is not easy to find all required dependencies this way, and it is even harder to find a working set of specific versions. But without further information, this is IMHO the best way to start. Good luck!

Upvotes: 5

Related Questions