A single, fast Scalingo buildpack for Trek host apps (Rails + esbuild + Yarn berry). It replaces the apt-buildpack + ruby-buildpack combination with one buildpack that:
- installs APT packages from
Aptfile, skippingapt-get updateand package resolution entirely when theAptfileis unchanged - installs Ruby with rv — precompiled, in seconds — using the version pinned in
.ruby-version(or.tool-versions/Gemfile.lock) - installs Node.js pinned by
.node-version(or.tool-versions), and the exact Yarn release pinned bypackage.json'spackageManagerfield, fetched directly from repo.yarnpkg.com — no more unpinned defaults - runs
yarn installexactly once, with a persistent cache, beforeassets:precompile - slims the slug after the build:
node_modules, Yarn machinery, and caches are dropped (Node.js never even enters the slug), roughly halving the image size of a typical Trek app — which speeds up deploys, restarts and scaling
Point the app at this buildpack, replacing any existing .buildpacks — a
.buildpacks file takes precedence over BUILDPACK_URL, so leaving one in
place means this buildpack never runs:
BUILDPACK_URL=https://github.com/etaminstudio/trek-buildpack/archive/refs/tags/v0.1.2.tar.gz
Pin a release rather than tracking the default branch: a build path that changes between two deploys is only noticed when a deploy breaks.
Use the archive form. Scalingo reads #ref as a branch, not a tag, so
…/trek-buildpack#v0.1.2 fails the download outright:
! fail to download and extract the custom buildpack: Invalid status code: 404 Not Found
Keep the app's Aptfile, Procfile, .ruby-version as generated by trek:install, and add a .node-version:
echo "24.13.0" > .node-version
| Variable | Effect |
|---|---|
TREK_BUILDPACK_RUNTIME_NODE=1 |
Ship Node.js in the slug (only needed if the app runs JS at runtime, e.g. execjs) |
TREK_BUILDPACK_PRUNE_SOURCEMAPS=1 |
Also remove .map files from the compiled assets |
The runtime environment defaults RAILS_ENV/RACK_ENV to production and enables RAILS_LOG_TO_STDOUT and RAILS_SERVE_STATIC_FILES; set them explicitly in the app's environment to override.
bin/detect # app detection (Gemfile.lock present)
bin/compile # orchestration; pinned tool versions live at the top
bin/release # fallback process types (apps normally ship a Procfile)
lib/*.sh # one module per concern: apt, ruby (rv), bundler, node/yarn, assets, slug
Build cache layout (under Scalingo's per-app cache dir): apt/ (deb archives + Aptfile fingerprint), rv/, xdg-cache/ (rv's Ruby tarballs), vendor-bundle (gems, keyed by Ruby version), node/, yarn/ (pinned Yarn CLI), yarn-global/ (berry package cache).
- The
Aptfilesupports one package per line with optional apt-get flags (libvips-tools --no-install-recommends), comments, and blank lines. Custom repo (:repo:) lines are not supported. - The gem cache is cleared whenever the Ruby version changes (native extensions are built against a specific Ruby).