中文文档 | 英文文档
nx-remotecache-qiniu
is an innovative task runner for @nrwl/nx
that leverages Qiniu Cloud Storage to create a remote cache. This unique approach allows all team members and CI servers to share a single cache, greatly enhancing efficiency and collaboration.
This package was built with nx-remotecache-custom 🙌
- Utilizes Qiniu Cloud Storage as a remote cache.
- Enables cache sharing among team members and CI servers.
- Built with nx-remotecache-custom.
Nx | Remote Cache |
---|---|
>= 17.0.0 <18 | >= 1.0.0 |
>= 18.0.0 < 19 | >= 2.0.0 |
To install, run the following command in your project directory:
npm install --save-dev nx-remotecache-qiniu
-
Add Nx to your workspace guide
-
npm install --save-dev nx-remotecache-qiniu
-
(Required)Obtaining Qiniu Cloud Keys
You can apply for keys at Qiniu Key Portal. Note that an individual can apply for up to 2 keys. For multiple users, create a Qiniu account and set sharing permissions in the created space.
Qiniu Cloud and Zone Information
- Qiniu Cloud: Qiniu Cloud Storage
- Zone Information: Qiniu Cloud Region and Endpoint
-
Creating a Bucket in Qiniu Cloud:
- Visit Qiniu Cloud Bucket Creation to create a new bucket.
- Choose the appropriate region for your bucket. You can refer to the region and endpoint information at Qiniu Cloud Region and Endpoint. Remember to note the Region ID.
- Upon successful creation of the bucket, you will receive a test domain from Qiniu Cloud.
-
Customizing CDN Domain:
- 2.1 (Optional) Apply for a domain if you do not already own one.
- 2.2 Domain Record Filing:
- For filing in China, you can use services like Aliyun (Alibaba Cloud) Filing or Tencent Cloud Filing.
- 2.3 Configuring EV SSL Certificate for Your Domain:
- Ensure your domain has an Extended Validation (EV) SSL Certificate for secure connections.
- 2.4 Configuring CNAME Record for Custom CDN Domain:
- Set up a CNAME record in your domain's DNS settings to enable your custom CDN domain.
The nx-remotecache-qiniu
requires the following options to be set:
Parameter | Description | Environment Variable | nx.json |
Notes |
---|---|---|---|---|
accessKey | Qiniu Cloud accessKey | NXCACHE_ACCESS_KEY |
accessKey |
Obtain from the Qiniu Cloud management console |
secretKey | Qiniu Cloud secretKey | NXCACHE_SECRET_KEY |
secretKey |
Obtain from the Qiniu Cloud management console |
bucket | Storage Bucket | NXCACHE_BUCKET |
bucket |
|
domain | Access Domain | NXCACHE_DOMAIN |
domain |
CDN acceleration is recommended |
zone | Zone | NXCACHE_ZONE |
zone |
Corresponds to the lowercase ZoneID |
private | Private Bucket Option (true/false) | NXCACHE_PRIVATE |
private |
Default is false, optional attribute |
expires | Cache Expiration Time (in seconds) | NXCACHE_EXPIRES |
expires |
Default is 3600, set to 0 for updating the uploadToken always |
You can also use environment variables prefixed with NXCACHE_
. Here's a format similar to the one you requested.
Now, let's move on to the Chinese version of the document.
nx.json
Configuration Demo, configure nx.json
as follows:
"tasksRunnerOptions": {
"default": {
"runner": "nx-remotecache-qiniu",
"options": {
"accessKey": "your_access_key",
"secretKey": "your_secret_key",
"bucket": "your_bucket_name",
"domain": "your_domain",
"zone": "your_zone",
"private": true_or_false,
"expires": expiration_time
}
}
}
Store files:
------------------------------------------------------------------------------
Stored output to remote cache: Nx Qiniu Cloud Storage - nx-remotecache-qiniu plugin
File: 14911649122709785563.tar.gz
------------------------------------------------------------------------------
Retreive files:
------------------------------------------------------------------------------
Remote cache hit: Nx Qiniu Cloud Storage - nx-remotecache-qiniu plugin
File: 14911649122709785563.tar.gz
------------------------------------------------------------------------------
> nx run header:build [remote cache]