Nx Private Cloud Advanced Configuration

Configure Memory Limits

By default, the Nx Cloud container is configured to run on an instance with 8GB of RAM.

If you have a container with 4GB of RAM, you can decrease the memory limits by setting the following env variables:

  • NX_CLOUD_FILE_SERVER_MEMORY_LIMIT=500

  • NX_CLOUD_API_MEMORY_LIMIT=800

  • NX_CLOUD_DATABASE_MEMORY_LIMIT=1

Example:

> docker create --name cloud \ -p 80:8081 \ -e NX_CLOUD_APP_URL="https://cloud.myorg.com" \ -e ADMIN_PASSWORD=admin \ -e NX_CLOUD_FILE_SERVER_MEMORY_LIMIT=500 \ -e NX_CLOUD_API_MEMORY_LIMIT=800 \ -e NX_CLOUD_DATABASE_MEMORY_LIMIT=1 \ -v /data/private-cloud:/data nxprivatecloud/nxcloud:latest

The right amount of RAM depends heavily on how you run Nx Cloud.

  • The NX_CLOUD_FILE_SERVER_MEMORY_LIMIT value is only relevant if you use the built-in file server.

  • The NX_CLOUD_DATABASE_MEMORY_LIMIT value is only relevant if you use the built-in database.

For instance, if you use S3 to store the cached artifacts and you host Mongo DB yourself, even 2GB might be sufficient. You can set the following limit:

  • NX_CLOUD_API_MEMORY_LIMIT=800

If you run everything in the Nx Cloud container, then 8GB is much preferred.

Configure Artifact Expiration When Using Built-in File Server

By default, the Nx Cloud container is going to remove cached artifacts after two weeks. You can change it by setting NX_CACHE_EXPIRATION_PERIOD_IN_DAYS when starting the container.

Example:

> docker create --name cloud \ -p 80:8081 \ -e NX_CLOUD_APP_URL="https://cloud.myorg.com" \ -e ADMIN_PASSWORD=admin \ -e NX_CACHE_EXPIRATION_PERIOD_IN_DAYS=5 \ -v /data/private-cloud:/data nxprivatecloud/nxcloud:latest

Self-Signed Certificates

If you have a self-signed certificate, you will have to provision NODE_EXTRA_CA_CERTS. The env variable should point to a PEM file with either your certificate, or the root certificate your certificate was created from. Though this can be accomplished with a CLI command like NODE_EXTRA_CA_CERTS=./tools/certs/cert.crt nx test myapp, you will most likely want to configure it as a global env variable (for instance in your .bashrc file).

A self-sign certificate registered in your OS won't be picked up by Node. Node requires you to provision NODE_EXTRA_CA_CERTS.

Connecting to an External Database

Nx Cloud uses MongoDB to store its metadata. By default, Nx Private Cloud is going to start a MongoDB instance and store its data in the provided volume. But you can also tell Nx Private Cloud to use a different MongoDB instance (e.g., if you are using MongoDB Atlas or Cosmos DB). To do this, provision the NX_CLOUD_MONGO_SERVER_ENDPOINT env variable when creating a container, like so: 

-e NX_CLOUD_MONGO_SERVER_ENDPOINT="mongodb://domain-with-mongo:27017"

By default, Nx Cloud requires Mongo 4.2+. If you are using an older version of Mongo (for instance, if you are using Cosmos DB), please add -e NX_CLOUD_USE_MONGO42=false.

Using External File Storage

By default, Nx Private Cloud is going to start a file server and store the cached artifacts in the provided volume. But you can also configure Nx Private Cloud to use an external file storage. At the moment, only S3 and Azure Blob are supported.

To configure S3 as a file storage, provision the AWS_S3_ACCESS_KEY_ID, AWS_S3_SECRET_ACCESS_KEY, and AWS_S3_BUCKET env variables when creating the Nx Cloud docker container, like so: 

... -e AWS_S3_ACCESS_KEY_ID="SOMEKEY" -e AWS_S3_SECRET_ACCESS_KEY="SOMESECRETKEY" -e AWS_S3_BUCKET="nx-cache-bucket-name"

If you are using an accelerated bucket, add: -e AWS_S3_ACCELERATED=true

If you are using a local S3 installation (e.g., Minio), you can set the endpoint as follows:

... -e AWS_S3_ENDPOINT="https://local-installation.myorg.com" -e AWS_S3_ACCESS_KEY_ID="SOMEKEY" -e AWS_S3_SECRET_ACCESS_KEY="SOMESECRETKEY" -e AWS_S3_BUCKET="nx-cache-bucket-name"

To configure Azure Blob as a file storage, provision the AZURE_CONNECTION_STRING, AZURE_CONTAINER env variables when creating the Nx Cloud docker container, like so:

... -e AZURE_CONNECTION_STRING="SOME-CONNECTION-STRING" -e AZURE_CONTAINER="files"

To obtain the AZURE_CONNECTION_STRING value go to your "Storage Account" and click on "Access Keys". You will also need to create a container in your storage account before starting the Nx Cloud container.

If you use an external file storage and an external MongoDB instance, you don't have to provision the volume.

Select an article to learn more about Nx Cloud