{"id":16058519,"url":"https://github.com/jonathanhefner/railbarge","last_synced_at":"2026-04-05T17:35:50.426Z","repository":{"id":141859709,"uuid":"609321362","full_name":"jonathanhefner/railbarge","owner":"jonathanhefner","description":"Turn-key Docker base images for Rails apps","archived":false,"fork":false,"pushed_at":"2023-03-08T17:52:48.000Z","size":9,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-17T23:33:23.680Z","etag":null,"topics":["docker","rails","ruby","ruby-on-rails"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/u/railbarge","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonathanhefner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-03T21:25:03.000Z","updated_at":"2024-03-28T16:59:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"7c197fbc-ed76-4a62-a209-3dd740c226cb","html_url":"https://github.com/jonathanhefner/railbarge","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jonathanhefner/railbarge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanhefner%2Frailbarge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanhefner%2Frailbarge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanhefner%2Frailbarge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanhefner%2Frailbarge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonathanhefner","download_url":"https://codeload.github.com/jonathanhefner/railbarge/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanhefner%2Frailbarge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31444702,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T15:22:31.103Z","status":"ssl_error","status_checked_at":"2026-04-05T15:22:00.205Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","rails","ruby","ruby-on-rails"],"created_at":"2024-10-09T03:21:43.726Z","updated_at":"2026-04-05T17:35:50.397Z","avatar_url":"https://github.com/jonathanhefner.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# railbarge\n\n`railbarge` is a set of Docker images that uses [`ONBUILD`][] instructions plus\n[`dockhand`][] to provide a turn-key `Dockerfile` UX for Rails applications.\n\n[`dockhand`]: https://github.com/jonathanhefner/dockhand\n[`ONBUILD`]: https://docs.docker.com/engine/reference/builder/#onbuild\n\n\nFor example, the following `Dockerfile` will work for many Rails applications:\n\n  ```dockerfile\n  ARG RUBY_VERSION=3.2.0\n\n  FROM railbarge/builder:ruby-$RUBY_VERSION as builder\n\n  FROM railbarge/app:ruby-$RUBY_VERSION\n  COPY --from=builder /artifacts /\n  ```\n\nIt will:\n\n* Set `RAILS_ENV` to `production`, and set `BUNDLE_ONLY` based on `RAILS_ENV` in\n  order to limit which packages and gems are installed (in both the builder and\n  final application stages).\n\n* Install buildtime-only apt packages in the builder stage [based on common\n  gems][buildtime packages] in your `Gemfile`, such as `libsqlite3-dev` if using\n  the `sqlite3` gem or `libpq-dev` if using the `pg` gem.\n\n  [buildtime packages]: https://github.com/jonathanhefner/dockhand/blob/v0.1.0/lib/dockhand/command.rb#L167-L171\n\n* Install gems as artifacts in the builder stage.\n\n* Install Node.js in the builder stage *if* your application has a\n  `.node-version` file or a `package.json` file with an `engines.node` value.\n\n* Set `NODE_ENV` to `production`.\n\n* Install Node.js modules as artifacts in the builder stage *if* your\n  application has a Yarn, NPM, or PNPM lock file.\n\n* Copy your application code as an artifact in the builder stage.\n\n* Precompile gem and application code with [`bootsnap`][] if present.\n\n  [`bootsnap`]: https://rubygems.org/gems/bootsnap\n\n* Precompile assets with a dummy `SECRET_KEY_BASE` if your application uses the\n  asset pipeline.  To use the actual `SECRET_KEY_BASE` from your credentials\n  file, set the `RAILS_MASTER_KEY` or `config/master.key` build secret:\n\n    ```console\n    $ RAILS_MASTER_KEY=\"...\" docker build --secret id=RAILS_MASTER_KEY -t my_cool_app .\n    $ docker build --secret id=config/master.key -t my_cool_app .\n    $ docker build --secret id=config/master.key,src=config/credentials/production.key -t my_cool_app .\n    ```\n\n* Fix binstubs in your application's `bin/` directory if they were generated on\n  Windows.\n\n* Install runtime apt packages in the final application stage [based on common\n  gems][runtime packages] in your `Gemfile`, such as `libsqlite3-0` if using the\n  `sqlite3` gem or `postgresql-client` if using the `pg` gem.\n\n  [runtime packages]: https://github.com/jonathanhefner/dockhand/blob/v0.1.0/lib/dockhand/command.rb#L160-L165\n\n* Set `RAILS_LOG_TO_STDOUT` and `RAILS_SERVE_STATIC_FILES` for Rails\n  applications generated prior to Rails 7.1.  (See [`rails/rails@2b1fa89`][]\n  and [`rails/rails@e8f481b`][].)\n\n  [`rails/rails@2b1fa89`]: https://github.com/rails/rails/commit/2b1fa89e442ecb99e262a34eb11bc1110912cd49\n  [`rails/rails@e8f481b`]: https://github.com/rails/rails/commit/e8f481b924c799bddab0b0d153b04e014f8193f3\n\n* Add an unprivileged user named `rails`, and set `USER` as `rails`.\n\n* Set `WORKDIR` for the final application stage as `/rails`.\n\n* Set `ENTRYPOINT` as your application's `bin/docker-entrypoint` and `CMD` as\n  `bin/rails server`.  If your application doesn't have a `bin/docker-entrypoint`\n  file, a fallback will be used that injects a call to `bin/rails db:prepare`\n  whenever the given command is `bin/rails server` (or an alias thereof).\n\n* Expose port 3000.\n\n* Lastly, the `Dockerfile` copies the artifacts from the builder stage to the\n  final application stage with `COPY --from=builder /artifacts /`.\n\nBehind the scenes, the above steps use [`--mount=type=cache`][] where\nappropriate to reduce build times and to prevent unnecessary files from being\nincluded in the final image.\n\n[`--mount=type=cache`]: https://docs.docker.com/engine/reference/builder/#run---mounttypecache\n\n\nMany of the above steps can be configured via build args.  For example:\n\n  ```dockerfile\n  # Override the Rails environment and the gem group to install (default: \"production\")\n  ARG RAILS_ENV=\"staging\"\n\n  # Specify multiple Rails environments to install gems for (default: RAILS_ENV)\n  ARG RAILS_ENVIRONMENTS=\"staging:test\"\n\n  # Specify additional apt packages for the build stage\n  ARG BUILDTIME_PACKAGES=\"libmagickwand-dev\"\n\n  # Specify additional apt packages for the final application stage\n  ARG RUNTIME_PACKAGES=\"imagemagick sudo\"\n\n  # Override the Node.js environment (default: \"production\")\n  ARG NODE_ENV=\"development\"\n\n  # Specify the subdirectory of your application that contains the package.json\n  # file, such as for a dedicated front-end client (default: \".\")\n  ARG PACKAGE_JSON_DIR=\"frontend\"\n\n  # Override the user name (default: \"rails\")\n  ARG USER=\"dude\"\n\n  # Override the application directory name and WORKDIR (default: \"/rails\")\n  ARG APP_DIR=\"/my_cool_app\"\n\n\n  ARG RUBY_VERSION=3.2.0\n\n  FROM railbarge/builder:ruby-$RUBY_VERSION as builder\n\n  FROM railbarge/app:ruby-$RUBY_VERSION\n  COPY --from=builder /artifacts /\n  ```\n\n(Note that the `ARG` statements must come **before** the first `FROM` statement;\notherwise, the `railbarge` images will not see them.)\n\n\nAnd, of course, you can append instructions to the stages themselves.  For\nexample, you can...\n\n* Disable `RAILS_LOG_TO_STDOUT` or `RAILS_SERVE_STATIC_FILES` for Rails\n  applications generated prior to Rails 7.1:\n\n    ```dockerfile\n    FROM railbarge/builder:ruby-2.7.7 as builder\n\n    FROM railbarge/app:ruby-2.7.7\n    ENV RAILS_LOG_TO_STDOUT=\"\"\n    ENV RAILS_SERVE_STATIC_FILES=\"\"\n    COPY --from=builder /artifacts /\n    ```\n\n* Enable [YJIT][]:\n\n    ```dockerfile\n    FROM railbarge/builder:ruby-3.2.0 as builder\n\n    FROM railbarge/app:ruby-3.2.0\n    ENV RUBY_YJIT_ENABLE=\"1\"\n    COPY --from=builder /artifacts /\n    ```\n\n  [YJIT]: https://github.com/Shopify/yjit\n\n* Switch to [jemalloc][]:\n\n    ```dockerfile\n    ARG RUNTIME_PACKAGES=\"libjemalloc2\"\n\n    FROM railbarge/builder:ruby-3.2.0 as builder\n\n    FROM railbarge/app:ruby-3.2.0\n    ENV LD_PRELOAD=\"/usr/lib/x86_64-linux-gnu/libjemalloc.so.2\"\n    ENV MALLOC_CONF=\"dirty_decay_ms:1000,narenas:2,background_thread:true\"\n    COPY --from=builder /artifacts /\n    ```\n\n  [jemalloc]: https://jemalloc.net/\n\n* Override `ENTRYPOINT` or `CMD`, such as to start [`foreman`][]:\n\n    ```dockerfile\n    FROM railbarge/builder:ruby-3.2.0 as builder\n\n    FROM railbarge/app:ruby-3.2.0\n    COPY --from=builder /artifacts /\n    ENTRYPOINT [\"bin/my-entrypoint\"]\n    CMD [\"foreman\", \"start\"]\n    ```\n\n  [`foreman`]: https://ddollar.github.io/foreman/\n\n* Run an extra NPM build step, such as for a dedicated front-end client:\n\n    ```dockerfile\n    ARG PACKAGE_JSON_DIR=\"client\"\n\n    FROM railbarge/builder:ruby-3.2.0 as builder\n    RUN cd client \\\n     \u0026\u0026 npm run build \\\n     \u0026\u0026 mv build/* ../public\n\n    FROM railbarge/app:ruby-3.2.0\n    COPY --from=builder /artifacts /\n    ```\n\n* Install Node.js as a build artifact so that it will be available at runtime,\n  such as to use [Puppeteer][]:\n\n    ```dockerfile\n    # Install Chromium for Puppeteer:\n    ARG RUNTIME_PACKAGES=\"chromium\"\n\n    FROM railbarge/builder:ruby-3.2.0 as builder\n    # Install Node.js as a build artifact:\n    RUN dockhand install-node --prefix=/artifacts/usr/local\n\n    FROM railbarge/app:ruby-3.2.0\n    # Point Puppeteer to Chromium:\n    ENV PUPPETEER_EXECUTABLE_PATH=\"/usr/bin/chromium\"\n    # Copy installed Node.js along with other artifacts:\n    COPY --from=builder /artifacts /\n    ```\n\n    [Puppeteer]: https://pptr.dev/\n\n\n## License\n\n[MIT License](LICENSE.txt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanhefner%2Frailbarge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonathanhefner%2Frailbarge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanhefner%2Frailbarge/lists"}