opensearch-project / OpenSearch-Dashboards

📊 Open source visualization dashboards for OpenSearch.
https://opensearch.org/docs/latest/dashboards/index/
Apache License 2.0
1.65k stars 857 forks source link

How to create React Production Build of OpenSearch Dashboard #7599

Open Siddhesh-Shinde opened 1 month ago

Siddhesh-Shinde commented 1 month ago

Versions: 2.13.0 OpenSearch Dashboard

Describe the issue: I have created a new plugin on top of the Opensearch Dashboard code. I'm intending to create a production build of the whole application. For any React application created using Create React App, we run the npm run build command. On looking at the OpenSearch Dashboard codebase, I found that the package.json contains custom scripts for build and almost everything. I also checked the Developer Guide readme present in OpenSearch Dashboard Github Repository. And I found a section named Building artifacts over there. Reference: https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/DEVELOPER_GUIDE.md#building-artifacts

It suggest running yarn build command. I tried running the command, but I'm getting self signed certificate error that too in the axios npm module. I'm wondering how to tackle this error or if there is any alternative way to create a React production build then please let me know. I would be thankful.

I have tried with export NODE_TLS_REJECT_UNAUTHORIZED=0 as well, but that also didn't work

Configuration: NA

Relevant Logs or Screenshots:

snipp

ruanyl commented 1 month ago

@Siddhesh-Shinde If you only added a new plugin but did not modify the OpenSearch-Dashboards code, you only need to build the plugin(you will get a .zip file) and install it to the official OpenSearch-Dashboards distributions

Siddhesh-Shinde commented 1 month ago

@Siddhesh-Shinde If you only added a new plugin but did not modify the OpenSearch-Dashboards code, you only need to build the plugin(you will get a .zip file) and install it to the official OpenSearch-Dashboards distributions

@ruanyl I have modified the OpenSearch Dashboard code as well like modifying the UI for instance, along with adding a fresh new plugin. How should I create the React production build then?

ruanyl commented 1 month ago

@Siddhesh-Shinde I tried in my local, but I cannot reproduce the error. By looking at the error message, it looks like it has something to do with your network condition.

Siddhesh-Shinde commented 1 month ago

@ruanyl Can you share the commands you executed and the corresponding logs so that I can have a glance at it

ruanyl commented 1 month ago
 yarn build --skip-os-packages

You should see the correct nodejs version downloaded successfully

$ scripts/use_node scripts/build --all-platforms --skip-os-packages
 info [  global  ] Verifying environment meets requirements
   │ succ Node.js version verified
   │ succ ✓ 0 sec

 info [  global  ] Cleaning artifacts from previous builds
   │ debg Deleting patterns: [
   │        '/Users/ruanyl/project/OpenSearch-Dashboards/build',
   │        '/Users/ruanyl/project/OpenSearch-Dashboards/target',
   │        '/Users/ruanyl/project/OpenSearch-Dashboards/.node_binaries'
   │      ]
   │ debg Deleted 2 files/directories
   │ succ ✓ 9 sec

 info [  global  ] Downloading node.js builds for all platforms
   │ debg Downloading shasum values for node version 18.19.0 from https://nodejs.org/dist/v18.19.0/SHASUMS256.txt
   │ debg Downloading shasum values for node version 14.21.3 from https://nodejs.org/dist/v14.21.3/SHASUMS256.txt
   │ warn There are no fallback Node.js versions released for darwin-arm64.
   │ debg Attempting download of https://nodejs.org/dist/v18.19.0/node-v18.19.0-linux-x64.tar.gz 153312ae9fe8684f345100e4d141a521dc542b36d8c1e09c31ac290eae98c62a
   │ debg Attempting download of https://nodejs.org/dist/v14.21.3/node-v14.21.3-linux-x64.tar.gz bef2685d9469058c1229cc7789e171861044fe3f70316ec744e9bf3609cd45ed
   │ debg Attempting download of https://nodejs.org/dist/v18.19.0/node-v18.19.0-darwin-x64.tar.gz 0a749fcdf5d6bf46e1c17b3ea01e050b4d1ec3f3073b14aa745527b45a759c74
   │ debg Attempting download of https://nodejs.org/dist/v18.19.0/node-v18.19.0-darwin-arm64.tar.gz 8907c42a968765b77730fb319458d63ec4ed009265f8012097c3a052407aa99b
   │ debg Attempting download of https://nodejs.org/dist/v18.19.0/node-v18.19.0-win-x64.zip 5311913d45e1fcc3643c58d1e3926eb85437b180f025fe5857413c9f02403645
   │ debg Attempting download of https://nodejs.org/dist/v14.21.3/node-v14.21.3-linux-arm64.tar.gz 044b7ec3fea04cd3815d26901ee37203dcc942688b72ee6eac96f6a1ca3cc63f
   │ debg Attempting download of https://nodejs.org/dist/v14.21.3/node-v14.21.3-win-x64.zip 47cfb919bb86ab681369636a9cb925e2bd61991aad1638b2e38e61ec956796a6
   │ debg Attempting download of https://nodejs.org/dist/v14.21.3/node-v14.21.3-darwin-x64.tar.gz a024f0dd5a4c1f951b79959c3e991b30a5919a734ab3e197ae0ef439e5a538b5
   │ debg Attempting download of https://nodejs.org/dist/v18.19.0/node-v18.19.0-linux-arm64.tar.gz 4297548671897a1ba6a9a78726cb3f53458048948b4f71d597886ccf799db603
   │ debg Downloaded https://nodejs.org/dist/v18.19.0/node-v18.19.0-linux-x64.tar.gz and verified checksum
   │ debg Downloaded https://nodejs.org/dist/v14.21.3/node-v14.21.3-darwin-x64.tar.gz and verified checksum
   │ debg Downloaded https://nodejs.org/dist/v14.21.3/node-v14.21.3-win-x64.zip and verified checksum
   │ debg Downloaded https://nodejs.org/dist/v14.21.3/node-v14.21.3-linux-arm64.tar.gz and verified checksum
   │ debg Downloaded https://nodejs.org/dist/v18.19.0/node-v18.19.0-darwin-x64.tar.gz and verified checksum
   │ debg Downloaded https://nodejs.org/dist/v18.19.0/node-v18.19.0-darwin-arm64.tar.gz and verified checksum
   │ debg Downloaded https://nodejs.org/dist/v18.19.0/node-v18.19.0-linux-arm64.tar.gz and verified checksum
   │ debg Downloaded https://nodejs.org/dist/v14.21.3/node-v14.21.3-linux-x64.tar.gz and verified checksum
   │ debg Downloaded https://nodejs.org/dist/v18.19.0/node-v18.19.0-win-x64.zip and verified checksum
   │ succ ✓ 10 sec
Siddhesh-Shinde commented 1 month ago
 yarn build --skip-os-packages

You should see the correct nodejs version downloaded successfully

$ scripts/use_node scripts/build --all-platforms --skip-os-packages
 info [  global  ] Verifying environment meets requirements
   │ succ Node.js version verified
   │ succ ✓ 0 sec

 info [  global  ] Cleaning artifacts from previous builds
   │ debg Deleting patterns: [
   │        '/Users/ruanyl/project/OpenSearch-Dashboards/build',
   │        '/Users/ruanyl/project/OpenSearch-Dashboards/target',
   │        '/Users/ruanyl/project/OpenSearch-Dashboards/.node_binaries'
   │      ]
   │ debg Deleted 2 files/directories
   │ succ ✓ 9 sec

 info [  global  ] Downloading node.js builds for all platforms
   │ debg Downloading shasum values for node version 18.19.0 from https://nodejs.org/dist/v18.19.0/SHASUMS256.txt
   │ debg Downloading shasum values for node version 14.21.3 from https://nodejs.org/dist/v14.21.3/SHASUMS256.txt
   │ warn There are no fallback Node.js versions released for darwin-arm64.
   │ debg Attempting download of https://nodejs.org/dist/v18.19.0/node-v18.19.0-linux-x64.tar.gz 153312ae9fe8684f345100e4d141a521dc542b36d8c1e09c31ac290eae98c62a
   │ debg Attempting download of https://nodejs.org/dist/v14.21.3/node-v14.21.3-linux-x64.tar.gz bef2685d9469058c1229cc7789e171861044fe3f70316ec744e9bf3609cd45ed
   │ debg Attempting download of https://nodejs.org/dist/v18.19.0/node-v18.19.0-darwin-x64.tar.gz 0a749fcdf5d6bf46e1c17b3ea01e050b4d1ec3f3073b14aa745527b45a759c74
   │ debg Attempting download of https://nodejs.org/dist/v18.19.0/node-v18.19.0-darwin-arm64.tar.gz 8907c42a968765b77730fb319458d63ec4ed009265f8012097c3a052407aa99b
   │ debg Attempting download of https://nodejs.org/dist/v18.19.0/node-v18.19.0-win-x64.zip 5311913d45e1fcc3643c58d1e3926eb85437b180f025fe5857413c9f02403645
   │ debg Attempting download of https://nodejs.org/dist/v14.21.3/node-v14.21.3-linux-arm64.tar.gz 044b7ec3fea04cd3815d26901ee37203dcc942688b72ee6eac96f6a1ca3cc63f
   │ debg Attempting download of https://nodejs.org/dist/v14.21.3/node-v14.21.3-win-x64.zip 47cfb919bb86ab681369636a9cb925e2bd61991aad1638b2e38e61ec956796a6
   │ debg Attempting download of https://nodejs.org/dist/v14.21.3/node-v14.21.3-darwin-x64.tar.gz a024f0dd5a4c1f951b79959c3e991b30a5919a734ab3e197ae0ef439e5a538b5
   │ debg Attempting download of https://nodejs.org/dist/v18.19.0/node-v18.19.0-linux-arm64.tar.gz 4297548671897a1ba6a9a78726cb3f53458048948b4f71d597886ccf799db603
   │ debg Downloaded https://nodejs.org/dist/v18.19.0/node-v18.19.0-linux-x64.tar.gz and verified checksum
   │ debg Downloaded https://nodejs.org/dist/v14.21.3/node-v14.21.3-darwin-x64.tar.gz and verified checksum
   │ debg Downloaded https://nodejs.org/dist/v14.21.3/node-v14.21.3-win-x64.zip and verified checksum
   │ debg Downloaded https://nodejs.org/dist/v14.21.3/node-v14.21.3-linux-arm64.tar.gz and verified checksum
   │ debg Downloaded https://nodejs.org/dist/v18.19.0/node-v18.19.0-darwin-x64.tar.gz and verified checksum
   │ debg Downloaded https://nodejs.org/dist/v18.19.0/node-v18.19.0-darwin-arm64.tar.gz and verified checksum
   │ debg Downloaded https://nodejs.org/dist/v18.19.0/node-v18.19.0-linux-arm64.tar.gz and verified checksum
   │ debg Downloaded https://nodejs.org/dist/v14.21.3/node-v14.21.3-linux-x64.tar.gz and verified checksum
   │ debg Downloaded https://nodejs.org/dist/v18.19.0/node-v18.19.0-win-x64.zip and verified checksum
   │ succ ✓ 10 sec

Gives me self signed certificate error mentioned above in image @ruanyl Is there any way to solve it, maybe by modifying the download.ts file present in src/dev/build/lib or some other alternative? This issue is a blocker to me.