Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

trek-buildpack

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, skipping apt-get update and package resolution entirely when the Aptfile is 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 by package.json's packageManager field, fetched directly from repo.yarnpkg.com — no more unpinned defaults
  • runs yarn install exactly once, with a persistent cache, before assets: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

Usage

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

Configuration

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.

Layout

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).

Notes

  • The Aptfile supports 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).

About

No description or website provided.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages