The zero-configuration Dockerfile generator for Ruby.

The Database Repository will be used for package information.


Add this line to your application's Gemfile development group:

group :development do
  gem 'boxing'

And then execute:

$ bundle install


Automatic Package Finder

This gem will read Gemfile and find any "knows" gem in the dependency database and put the necessary package as a dependency for build and runtime.

That means you never need to know the actual package and don't need to write your Dockerfile by hand.

Optimized Size

By the default, the base image is depend on ruby:[VERSION]-alpine which is minimal size for Ruby in most cases.

To let your image as small as possible, this gem uses multi-stage and strip useless artifacts while the c-extension compiling.

The final Rails image will be around 100MB and can be flexible to delivery to any environment.

We suggest using puma as the webserver to avoid the extra dependency to keep the image small.

Bootsnap Precompile (Experimental)

If your gem dependency included bootsnap the generated Dockerfile will add precompile options to speed up the application bootstrap.

AWS Lambda Runtime Interface Client

When the aws_lambda_ric gem is detected, the boxing will choose to use bin/aws_lambda_ric as entrypoint.

To make it works correctly, run bundle binstub aws_lambda_ric to make it can run it correctly.


To identity your image version, the default build argument REVISION will be configured by default.

You can add extra options when you are building images in your CI.

# GitLab CI example
  extends: .docker
  stage: package
    - docker build
      --cache-from $RAILS_IMAGE:latest
      --build-arg REVISION=${CI_COMMIT_SHORT_SHA}
      --build-arg BUILDKIT_INLINE_CACHE=1
      --tag $RAILS_IMAGE:latest .

It will helpful for Sentry to detect the released version or use <%= ENV['REVISION'] %> to help you identify the current version.



To generate Dockerfile for current project

bundle exec boxing generate


To update the database for package information

bundle exec boxing update

If the generated Dockerfile is not satisfy, please try to update it.


If config/boxing.rb is found, it will be loaded and change the generated Dockerfile and .dockerignore

Source Code Root

Boxing.config do |c|
  c.root = '/var/www'

Customize Entrypoint

Boxing.config do |c|
  c.entrypoint = ['bin/rails']

Customize Command

Boxing.config do |c|
  c.command = ['server', '-b', '']

Ignore Files

Boxing.config do |c|
  c.ignores = %w[

Extra Packages

Boxing.config do |c|
  c.build_packages = %w[nodejs]
  c.runtime_packages = %w[git]

Revision Information

Boxing.config do |c|
  c.revision = true

When building the image, you have to add --build-arg REVISION=... to set your revision name to compile it correctly.

Sentry Support

Boxing.config do |c|
  c.sentry_release = true

When building the image, you have to add --build-arg SENTRY_RELEASE=... to set your release name to compile it correctly.

Assets Precompile

This feature is disabled by default and suggest to use CI to build it.

Boxing.config do |c|
  c.assets_precompile = true
  # If not given the `node -v` will be execute
  c.node_version = '14.18'

When building the image, you have to add --build-arg RAILS_MASTER_KEY=... to set your production key to compile it correctly.

Health Check

Boxing.config do |c|
  c.health_check = true
  c.health_check_path = '/api/status.json'

If liveness gem is installed, the health check will enabled by default with /status path.


  • [x] Dockerfile generator
  • [x] .dockerignore generator
    • [x] Common ignore files
    • [x] Customizable ignore files
  • [ ] Docker Compose generator
    • [ ] Production Version
    • [x] Development Version
  • [x] Allow run Assets Precompile in Container
    • [ ] Disable RAILS_SERVE_STATIC_FILES by default
  • [x] Customize config file config/boxing.rb
    • [x] Customize APP_ROOT
    • [x] Extra packages
    • [ ] DSL to customize Dockerfile
    • [ ] Build Stage
    • [x] Entrypoint
    • [x] Command
    • [x] Expose Port
  • [x] Health Check
    • [x] Liveness gem detection
    • [x] Add curl for web application
  • [x] Entrypoint Detection
    • [x] Openbox (Suggested)
    • [x] Ruby on Rails
    • [x] Rack (Default)
    • [x] AWS Lambda Runtime Interface Client
    • [x] Lamby supported (Default)
    • [x] SQS ActiveJob Lambda Handler
  • [ ] Package Database
    • [x] Built-in (Move to standalone repoistory in future)
    • [x] Standalone Repoistory
    • [x] Support gems from git repoistory
    • [x] Customize Source
    • [ ] Base Image
    • [x] Alpine
    • [ ] Ubuntu
    • [ ] Filter by Ruby Version
    • [ ] Filter by Gem Version


After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to


Bug reports and pull requests are welcome on GitHub at This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

Code of Conduct

Everyone interacting in the Boxing project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.