Skip to content

Self-host Cache

The Tuist cache service can be self-hosted to provide a private binary cache for your team. This is most useful for organizations with large artifacts and frequent builds, where placing the cache closer to your CI infrastructure reduces latency and improves cache efficiency. By minimizing the distance between your build agents and the cache, you ensure that network overhead doesn't negate the speed benefits of caching.

INFO

Self-hosting cache nodes requires an Enterprise plan.

You can connect self-hosted cache nodes to either the hosted Tuist server (https://tuist.dev) or a self-hosted Tuist server. Self-hosting the Tuist server itself requires a separate server license. See the server self-hosting guide.

Prerequisites

  • Docker and Docker Compose
  • S3-compatible storage bucket
  • A running Tuist server instance (hosted or self-hosted)

Deployment

The cache service is distributed as a Docker image at ghcr.io/tuist/cache. We provide reference configuration files in the cache directory.

TIP

We provide a Docker Compose setup because it's a convenient baseline for evaluation and small deployments. You can use it as a reference and adapt it to your preferred deployment model (Kubernetes, raw Docker, etc.).

Configuration files

bash
curl -O https://raw.githubusercontent.com/tuist/tuist/main/cache/docker-compose.yml
mkdir -p docker
curl -o docker/nginx.conf https://raw.githubusercontent.com/tuist/tuist/main/cache/docker/nginx.conf

Environment variables

Create a .env file with your configuration.

TIP

The service is built with Elixir/Phoenix, so some variables use the PHX_ prefix. You can treat these as standard service configuration.

env
# Secret key used to sign and encrypt data. Minimum 64 characters.
# Generate with: openssl rand -base64 64
SECRET_KEY_BASE=YOUR_SECRET_KEY_BASE

# Public hostname or IP address where your cache service will be reachable.
PUBLIC_HOST=cache.example.com

# URL of the Tuist server used for authentication (REQUIRED).
# - Hosted: https://tuist.dev
# - Self-hosted: https://your-tuist-server.example.com
SERVER_URL=https://tuist.dev

# S3 Storage configuration
S3_BUCKET=your-cache-bucket
S3_HOST=s3.us-east-1.amazonaws.com
S3_ACCESS_KEY_ID=your-access-key
S3_SECRET_ACCESS_KEY=your-secret-key
S3_REGION=us-east-1

# CAS storage (required for non-compose deployments)
CAS_STORAGE_DIR=/cas
VariableRequiredDefaultDescription
SECRET_KEY_BASEYesSecret key used to sign and encrypt data (minimum 64 characters).
PUBLIC_HOSTYesPublic hostname or IP address of your cache service. Used to generate absolute URLs.
SERVER_URLYesURL of your Tuist server for authentication. Defaults to https://tuist.dev
CAS_STORAGE_DIRYesDirectory where CAS artifacts are stored on disk. The provided Docker Compose setup uses /cas.
S3_BUCKETYesS3 bucket name.
S3_HOSTYesS3 endpoint hostname.
S3_ACCESS_KEY_IDYesS3 access key.
S3_SECRET_ACCESS_KEYYesS3 secret key.
S3_REGIONYesS3 region.
CAS_DISK_HIGH_WATERMARK_PERCENTNo85Disk usage percentage that triggers LRU eviction.
CAS_DISK_TARGET_PERCENTNo70Target disk usage after eviction.
PHX_SOCKET_PATHNo/run/cache/cache.sockPath where the service creates its Unix socket (when enabled).
PHX_SOCKET_LINKNo/run/cache/current.sockSymlink path that Nginx uses to connect to the service.

Start the service

bash
docker compose up -d

Verify the deployment

bash
curl http://localhost/up

Configure the cache endpoint

After deploying the cache service, register it in your Tuist server organization settings:

  1. Navigate to your organization's Settings page
  2. Find the Custom cache endpoints section
  3. Add your cache service URL (for example, https://cache.example.com)
mermaid
graph TD
  A[Deploy cache service] --> B[Add custom cache endpoint in Settings]
  B --> C[Tuist CLI uses your endpoint]

Once configured, the Tuist CLI will use your self-hosted cache.

Volumes

The Docker Compose configuration uses three volumes:

VolumePurpose
cas_dataBinary artifact storage
sqlite_dataAccess metadata for LRU eviction
cache_socketUnix socket for Nginx-service communication

Health checks

  • GET /up — Returns 200 when healthy
  • GET /metrics — Prometheus metrics

Monitoring

The cache service exposes Prometheus-compatible metrics at /metrics.

If you use Grafana, you can import the reference dashboard.

Upgrading

bash
docker compose pull
docker compose up -d

The service runs database migrations automatically on startup.

Troubleshooting

Cache not being used

If you expect caching but are seeing consistent cache misses (for example, the CLI is repeatedly uploading the same artifacts, or downloads never happen), follow these steps:

  1. Verify the custom cache endpoint is correctly configured in your organization settings.
  2. Ensure your Tuist CLI is authenticated by running tuist auth login.
  3. Check the cache service logs for any errors: docker compose logs cache.

Socket path mismatch

If you see connection refused errors:

  • Ensure PHX_SOCKET_LINK points to the socket path configured in nginx.conf (default: /run/cache/current.sock)
  • Verify PHX_SOCKET_PATH and PHX_SOCKET_LINK are both set correctly in docker-compose.yml
  • Verify the cache_socket volume is mounted in both containers

Released under the MIT License.