Nx Private Cloud Advanced Configuration

Configure Memory Limits

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

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

  • NX_CLOUD_FILE_SERVER_MEMORY_LIMIT=600

  • NX_CLOUD_API_MEMORY_LIMIT=600

  • NX_CLOUD_DATABASE_MEMORY_LIMIT=1

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

  • NX_CLOUD_FILE_SERVER_MEMORY_LIMIT=1000

  • NX_CLOUD_API_MEMORY_LIMIT=1000

  • NX_CLOUD_DATABASE_MEMORY_LIMIT=3

Example:

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

Configure Artifact Expiration

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_MODE=private-community \ -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 points to a PEM file with either your certificate, or the root certificate you created your certificate from. Even though you can do it like this NODE_EXTRA_CA_CERTS=./tools/certs/cert.crt nx test myapp, most likely you will want to configure it as a global env variable (for instance in your bashrc).

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 it, provision the NX_CLOUD_MONGO_SERVER_ENDPOINT env variable when creating a container, like this: -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 this: 

... -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 this:

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

To obtain AZURE_CONNECTION_STRING go to your "Storage Account" and click on "Access Keys". You 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