Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Railway 5 min read Case study mediumAdept

Why We’re Moving on From Nix

Railway replaced its Nix-based builder Nixpacks with Railpack, a Go rewrite that generates BuildKit LLB graphs directly instead of linear Dockerfiles. Nix's commit-pinned versioning made patch-level versions hard to support and turned default bumps into surprise build failures. A single /nix/store layer bloated images, and an injected deployment ID env var invalidated caches. Railpack uses Mise for exact version resolution, locks dependencies from successful builds, and runs an analyze → JSON plan → BuildKit graph pipeline. It also hashes only the env vars each step uses so layers cache correctly, and uses BuildKit secrets, cutting base image sizes by 38% (Node) to 77% (Python).

Assumes: Docker image layersBuildKit basicsNix package manager

Related posts

  • Manually Optimize Deployments on Railway

    Railway mediumAdept

    Deploying a FastAPI app on Railway three ways shows large speed differences: the default Nixpacks builder took 1m27s, a slim-based custom Dockerfile took 15 seconds, and pulling a pre-built image from Docker Hub took 6 seconds. Dockerfile size tips include slim/alpine base images, multi-stage builds, fewer layers and .dockerignore. The setup is then automated with two GitHub Actions workflows: one builds and pushes the image to Docker Hub on push to main, and a second triggers a Railway CLI redeploy when the first completes.

  • Dependency prefixes are a supply chain risk: let's fix them

    Sourcegraph mediumAdept

    SemVer range prefixes like ^, ~ and wildcards in package.json act as a trust policy that lets compromised or hijacked packages flow into CI and production on the next install. The recommended controls are to commit lockfiles and install with npm ci, pnpm --frozen-lockfile or yarn --immutable, pin exact versions for high-blast-radius packages such as build tools, auth libraries and native-binding deps, set save-exact defaults, disable install scripts with an allowlist for exceptions, and run audits against the locked tree. To roll this out across hundreds of repositories, a Sourcegraph Batch Changes spec with a Node script rewrites React dependency ranges to approved exact versions and refreshes lockfiles without running scripts.

  • Counting to 3 with a new builder processing 50M+ monthly builds

    Railway mediumAdept

    Railway replaced its docker-buildx-on-GCP-VMs build system with Builder v3: 256-vCPU bare-metal hosts split into eight 32-vCPU microVM build cells running buildkitd, scheduled with a 1-of-3 ring to keep BuildKit caches warm, now peaking at 66,000 builds per hour. Collapsing a host/guest split (workflow → gRPC over vsock → guest handler) into one standalone builder process cut about 20 seconds from cached builds. Rollout problems included VM bridge networking failures that forced a rollback, unreliable DNS (fixed with embedded CoreDNS), clock drift breaking cert validation, and stuck builds from runc workers starving buildkitd, fixed with cgroup v2 slices. Reading layer metadata from OCI manifests instead of decompressing layers was about 15× faster and saved roughly 10 seconds per build.

  • Working with NX, Railway and CI/CD

    Railway mediumAdept

    A GitHub Actions workflow can deploy only the NX monorepo apps affected by a push to Railway, replacing Railway's built-in GitHub trigger. The setup sets NIXPACKS_NX_APP_NAME, creates one Railway environment and project token per branch, and stores the tokens as GitHub secrets named RAILWAY_TOKEN__<project>_<environment>. On each push the workflow works out a base commit that survives force pushes, then lints and builds the affected projects. A bash script uses `nx print-affected` to find the affected apps, looks up each app's token from a dumped secrets JSON file, and runs `railway up --detach`. Dumping the secrets to a file is flagged as risky in public repos, and `--detach` keeps long container builds from using up GitHub Actions minutes.

  • Improving machine learning iteration speed with faster application build and packaging

    Meta Engineering mediumAdept

    Meta cut ML engineers' build and packaging overhead by double-digit percentages by tackling build non-determinism, pruning dependencies, and replacing monolithic XAR executables with an incremental Content Addressable Filesystem (CAF). Non-determinism from compilers and build rules is mitigated inside the Remote Execution service that Buck2 sends nearly all build actions to, so stable warm revisions can reuse cached outputs. CAF describes each executable as a flat manifest of content digests, skips uploads already in CAS, and fetches only missing content via per-host CAS daemons that share data peer-to-peer over Owl. Btrfs compression and copy-on-write keep on-disk size close to XAR while sharing files across executables. Planned next steps are lazy on-demand fetching (LazyCAF) and putting all ML engineers on uniform revisions to raise cache hit rates.

The quest for software engineering knowledge.

Look:
Layout: