Repository navigation
Add Ruby 3.2.11, Bundler, MySQL headers, and Yarn to the anvil image - #91
Merged
Merged
Conversation
Debian trixie ships Ruby 3.3, so a project pinned to 3.2 needs the interpreter built the way Python already is: a ruby-builder stage compiles the release tarball into /opt/ruby, checked against its published SHA-256, and installs Bundler 2.6.9 so a lockfile bundled with it does not trigger a version switch. /opt/ruby belongs to root and the harness runs as the anvil user, so GEM_HOME points under the anvil home, where bundle install can write and which persists for every harness that mounts the home. Its bin directory goes at the end of PATH, not the front: the image PATH is also the root phase's, which runs chown, adduser, and gosu by bare name, so a session-writable directory ahead of /usr/bin would let a session plant a command for root to run on the next start. A test holds the Dockerfile's PATH to that. The yaml, ffi, gmp, and zlib headers go into the runtime stage too: libruby and its psych, fiddle, and zlib extensions link against those libraries, and native gems compile against the headers.
A Rails app on MySQL cannot bundle without them: the mysql2 gem compiles against libmysqlclient, which default-libmysqlclient-dev provides (as MariaDB's compatible client on trixie), and assets:precompile runs Shakapacker's JS build, which installs its packages with yarn. Yarn comes from corepack, which Node 24 bundles, rather than a global npm install: Yarn 1 refuses to run in a project whose packageManager names Yarn 2 or later, while corepack's shim runs whatever release that field names and falls back to Yarn 1 when there is none. The shim fetches the release on first use, so the download prompt is turned off for a session with no one to answer it, and so is auto-pinning, which would write packageManager into the project's package.json.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lets an agent run
bundle installandassets:precompilefor a Rails app on Ruby 3.2.11, Bundler 2.6.9,mysql2, and Shakapacker.ruby-builderstage compiles 3.2.11 into/opt/rubyand checks the tarball's SHA-256 (trixie ships 3.3). It also installs Bundler 2.6.9 and puts the yaml/ffi/gmp/zlib headers in the runtime image.GEM_HOME=/home/anvil/.gem, because/opt/rubybelongs to root.default-libmysqlclient-devformysql2.packageManagerstill works (Yarn 1 refuses to run there). The download prompt and auto-pinning are turned off.$GEM_HOME/bingoes at the end ofPATH. Root's startup phase uses the samePATH, so a writable directory at the front would let a session plant commands for root. A newImagePathOrdertest enforces the order.Changing
RUBY_VERSIONalso means changingRUBY_SHA256.