Skip to content

Latest commit

 

History

History
 
 

ruby

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Image on Docker Hub: https://hub.docker.com/r/iron/ruby

Using this image for your Ruby apps/programs

1. Vendor dependencies (if you update your Gemfile, rerun this):

docker run --rm -v "$PWD":/worker -w /worker iron/ruby:dev bundle install --standalone --clean

If you're using Nokogiri, use this one:

docker run --rm -v "$PWD":/worker -w /worker iron/ruby:dev sh -c 'bundle config --local build.nokogiri --use-system-libraries && bundle install --standalone --clean'

Then require the vendored gems. Notice in hello.rb, we add the following so it uses the vendored gems:

require_relative 'bundle/bundler/setup'

2. Test your code

Test your code:

docker run --rm -it -v $PWD:/app -w /app iron/ruby ruby hello.rb

Notice we're using iron/ruby:dev to build and iron/ruby to run. iron/ruby is much smaller.

Building an image for your Ruby app:

Make a Dockerfile:

FROM iron/ruby

WORKDIR /app
ADD . /app

ENTRYPOINT ["ruby", "hello.rb"]

Build the image:

docker build -t username/imagename:latest .

Push it to Docker Hub:

docker push username/imagename