Image on Docker Hub: https://hub.docker.com/r/iron/ruby
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'
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.
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