Nx
Speed up your Nx monorepo builds with Shipfox's built-in self-hosted remote cache
Nx is a powerful build system and monorepo tool with first-class support for remote caching. Its remote cache stores task outputs so that any CI job or developer machine can reuse the result of a task that has already been run with the same inputs.
Shipfox provides a built-in Nx-compatible remote cache colocated with your runners at $SHIPFOX_NX_URL. Cache reads and writes happen over the local network, making them significantly faster than reaching out to an external cache server.
How it works
When an Nx task finishes, its output is stored in the remote cache under a hash of the task inputs (source files, configuration, and environment). On the next run, Nx checks the remote cache before executing: if a matching entry is found, the cached output is restored instead.
Shipfox implements the Nx self-hosted remote cache protocol. In automatic mode, the required variables are pre-configured before your job starts.
Automatic setup
When automatic caching is enabled, Shipfox pre-configures the following environment variables on every runner:
| Variable | Value |
|---|---|
NX_SELF_HOSTED_REMOTE_CACHE_SERVER | Shipfox's Nx cache endpoint |
NX_SELF_HOSTED_REMOTE_CACHE_ACCESS_TOKEN | shipfox |
Your workflows run nx commands as-is, no changes needed.
- name: Install dependencies
run: npm install
- name: Build
run: npx nx build my-app
- name: Test
run: npx nx run-many -t testAutomatic caching is enabled by default. You can disable it per tool from your Organization Settings in the Shipfox dashboard if you prefer to manage the configuration yourself.
Manual setup
If you want full control over the configuration, use the $SHIPFOX_NX_URL environment variable exposed on every runner and set the Nx variables yourself.
- name: Configure Nx remote cache
run: |
echo "NX_SELF_HOSTED_REMOTE_CACHE_SERVER=$SHIPFOX_NX_URL" >> "$GITHUB_ENV"
echo "NX_SELF_HOSTED_REMOTE_CACHE_ACCESS_TOKEN=shipfox" >> "$GITHUB_ENV"
- name: Install dependencies
run: npm install
- name: Build
run: npx nx build my-appNX_SELF_HOSTED_REMOTE_CACHE_ACCESS_TOKEN must be set to a non-empty string. The Shipfox cache server accepts any value; shipfox is a sensible default.
Nx self-hosted remote cache requires Nx 19.8 or later. Make sure your nx package is up to date.