diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..8d1cdf70 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM ruby:2.6.6-slim + +# Install build tooks. +RUN apt update && apt install -y build-essential + +# Working folder. +RUN mkdir /app +WORKDIR /app + +# Setup bundler. +RUN gem update --system 3.1.4 && \ + gem install bundler -v 2.1.4 + +# Entrypoint script will install gems. +COPY docker-entrypoint.sh docker-entrypoint.sh +RUN chmod +x docker-entrypoint.sh +ENTRYPOINT ["sh", "/app/docker-entrypoint.sh"] \ No newline at end of file diff --git a/Gemfile b/Gemfile index c36df534..a4a7840b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,34 +1,32 @@ source "http://rubygems.org" -# @param [Array] versions compatible ruby versions -# @return [Array] an array with mri platforms of given versions -def mries(*versions) - versions.map do |v| - %w(ruby mingw x64_mingw).map do |platform| - "#{platform}_#{v}".to_sym unless platform == "x64_mingw" && v < "2.0" - end.delete_if &:nil? - end.flatten -end - -if RUBY_VERSION < '1.9' || defined?(JRUBY_VERSION) - gem "ruby-debug-base", :platforms => [:jruby, *mries('18')] -end - -if RUBY_VERSION && RUBY_VERSION >= "1.9" - gem "ruby-debug-base19x", ">= 0.11.32", :platforms => mries('19') -end - -if RUBY_VERSION && RUBY_VERSION >= "2.0" - gem "debase", "~> 0.2", ">= 0.2.2", :platforms => mries('20', '21', '22', '23', '24', '25') +# Need to limit Debase to 0.2.2 for Ruby 2.0 so the tests +# pass but it appears that Debase 2.4 will work when Debase +# is using in a project. The error in the tests is: +# +# Error: test_catchpoint_basics(RDCatchpointTest): RuntimeError: expected "suspended" start_element, but got "end_document: []" +# +if RUBY_VERSION + if RUBY_VERSION < "1.9" + gem "ruby-debug-base" + elsif RUBY_VERSION < "2.0" + gem "ruby-debug-base19x", ">= 0.11.32" + elsif RUBY_VERSION < "2.1" + gem "debase", "<= 0.2.2" + else + gem "debase", ">= 0.2.2" + end end gemspec -group :development do - gem "bundler" -end +group :development, :test do + # Bundler 1.9.0 has an error on Ruby 1.9.3: + # + # https://github.com/rubygems/bundler/issues/3492 + # + gem "bundler", "> 1.9" -group :test do if RUBY_VERSION < "1.9" gem "test-unit", "~> 2.1.2" else diff --git a/README.md b/README.md index df075152..9c66d239 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ The 'ruby-debug-ide' gem provides the protocol to establish communication between the debugger engine (such as [debase](https://rubygems.org/gems/debase) or [ruby-debug-base](https://rubygems.org/gems/ruby-debug-base)) and IDEs (for example, RubyMine, Visual Studio Code, or Eclipse). 'ruby-debug-ide' redirect commands from the IDE to the debugger engine. Then, it returns answers/events received from the debugger engine to the IDE. To learn more about a communication protocol, see the following document: [ruby-debug-ide protocol](protocol-spec.md). -## Install debugging gems +## Install the debugging gems Depending on the used Ruby version, you need to add/install the following debugging gems to the Gemfile: - Ruby 2.x - [ruby-debug-ide](https://rubygems.org/gems/ruby-debug-ide) and [debase](https://rubygems.org/gems/debase) - Ruby 1.9.x - [ruby-debug-ide](https://rubygems.org/gems/ruby-debug-ide) and [ruby-debug-base19x](https://rubygems.org/gems/ruby-debug-base19x) @@ -28,4 +28,38 @@ ports: - "3000:3000" - "26162:26162" ``` -Note that all ports above should be exposed in the Dockerfile. \ No newline at end of file +Note that all ports above should be exposed in the Dockerfile. + +## Developing Ruby Debug IDE + +To develop the Ruby Debug IDE you can either setup Ruby on your host machine or use the Docker container provided. Currently there is just the one container but more can be added for different Ruby versions if needed. The Ruby Debug IDE should run using all versions of Ruby. + +### Host + +Install Ruby. We recommend using [RVM](https://rvm.io/) or [Rbenv](https://github.com/rbenv/rbenv). + +### Docker + +In the root folder run: + +```bash +docker-compose build +``` + +Then run the container: + +```bash +docker-compose run app bash +``` + +Note: The gems are not installed until the container is run and the [docker-entrypoint.sh](docker-entrypoint.sh) is called. + +### Tests + +Once you have your development environment setup make sure the tests all pass: + +```bash +rake +``` + +You should now be good to go. Having trouble getting your development environment setup then open an [issue](https://github.com/corgibytes/ruby-debug-ide/issues). \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..a1411847 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3.7' +services: + app: + build: . + volumes: + - .:/app + - bundler-data:/usr/local/bundle + ports: + - "1234:1234" # RubyMine + +volumes: + bundler-data: \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 00000000..2df0417d --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +bundle check || bundle install +bundle clean --force + +exec "$@" \ No newline at end of file