Skip to main content
A build sometimes needs a service that wants a credential, such as a private package registry or a test API. A destination lets the build use the service and never hold the secret. The build calls a local address. The runner forwards each request to the service’s HTTPS address and adds the credential.
Inside the build, npm install calls a local address, 127.0.0.1:3129, holding no secret. The runner adds your secret, read on the host, and forwards the request over HTTPS to npm.acme.dev.Inside the build, npm install calls a local address, 127.0.0.1:3129, holding no secret. The runner adds your secret, read on the host, and forwards the request over HTTPS to npm.acme.dev.

Before you start

Other ways a build gets a variable

A destination is not the only way. A self-hosted build can also get the plain build variables of the factory. The runner’s owner and an Owner or Admin must both approve this once. See Build variables on a self-hosted runner. A variable the factory sends to a service reaches no self-hosted build yet.

Add a destination

A destination’s header names a variable of the runner’s own environment, such as ${NPM_TOKEN}. The runner refuses to start while that variable is unset. So store the secret first.
1

Store the secret in the runner's environment

Under the service that outerlayer runner init sets up, the runner’s environment is the file runner.env beside the config file. That is ~/.outerlayer-runner/runner.env when you followed Set up your first host, and ~/.outerlayer/runner.env under an account of its own.
read -rs keeps the secret off the screen and out of your shell history. The umask and chmod make the file readable by your account only. On macOS and Windows, run the commands inside the Linux VM or the WSL2 distribution.A runner in the runner image reads the secret from the file that you pass with --env-file. Put the line in that file. See Start the runner.
2

Add the destination to the config file

List destinations in runner.build.destinations:
3

Restart the runner

The service reads runner.env only when it starts:
If you gave the service another name with --unit-name, restart that unit. For a runner in the runner image, create the container again.
A build’s record names the destinations that the build called, never a secret. See outerlayer work status --json, under claims. outerlayer runner check reads a header’s variables from your shell, not from runner.env. It reports <VAR> is not set in the runner's environment unless your shell holds the variable.

The keys of a destination

A runner takes at most 17 destinations. It refuses a key that is not in this table. The runner refuses these variable names:
  • In env, a name that the runner sets itself, that another destination sets, or that build.variables names.
  • In header, a variable that env or build.variables also names. The build could then read the secret.

The local address

The local address depends on how the build runs:
  • A container or microVM build reaches the first destination in the list at http://127.0.0.1:3129/, the second at port 3130, and so on.
  • With your own hooks, a command run through an exec uses the same ports. The hook must relay each port with outerlayer broker-relay --forward. See The tunnel and the proxy.
  • With your own hooks and no exec, the command reaches the destination on a loopback port that the runner chooses.
With your own hooks, every user of the host can call a destination while a build runs. Do not use destinations there on a host that other people use.

What the runner forwards

The runner sets the destination’s header on each request. It drops the Authorization, Proxy-Authorization and Cookie headers that the build sends. It passes every other header as sent. These limits apply:
  • The runner does not rewrite answers. A tool that follows an absolute URL in an answer leaves the local address, and reaches the upstream with no credential. Set the tool to stay on the local address, such as npm’s NPM_CONFIG_REPLACE_REGISTRY_HOST=always above. pip and Cargo have no such setting.
  • A WebSocket connection does not pass.
  • The runner drops a request when the upstream sends nothing for 10 minutes.

Settings for common tools

Each row is a destination with the tool’s own variable in env:

When a request fails

When the runner cannot forward a request, it answers 502 with a short text that names the destination: If a new destination does not appear in builds, read the runner’s log. A config re-read rejected line that names the destination’s header means its variable is unset. The runner then keeps its earlier config, and applies no other edit to the file. Store the variable and restart the runner.

When a secret must be a variable

A destination works only when the tool can be pointed at another address. The runner does not decrypt HTTPS traffic from the build. So a tool that reaches only the service’s real address cannot use a destination, such as a SaaS client with the address compiled in. For such a tool, name the secret in build.variables. It is then in the build’s environment. The build’s record names the variable, never its value.
Every program in the build can read a secret in build.variables. Give it the narrowest credential the tool accepts.