Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create React Production Build of OpenSearch Dashboard #7599

Closed
Siddhesh-Shinde opened this issue Jul 31, 2024 · 7 comments
Closed

How to create React Production Build of OpenSearch Dashboard #7599

Siddhesh-Shinde opened this issue Jul 31, 2024 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@Siddhesh-Shinde
Copy link

Siddhesh-Shinde commented Jul 31, 2024

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

@Siddhesh-Shinde Siddhesh-Shinde added bug Something isn't working untriaged labels Jul 31, 2024
@Siddhesh-Shinde Siddhesh-Shinde changed the title [BUG] How to create React Production Build of OpenSearch Dashboard Jul 31, 2024
@ruanyl
Copy link
Member

ruanyl commented Aug 2, 2024

@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
Copy link
Author

Siddhesh-Shinde commented Aug 2, 2024

@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
Copy link
Member

ruanyl commented Aug 2, 2024

@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
Copy link
Author

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

@ruanyl
Copy link
Member

ruanyl commented Aug 2, 2024

 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
Copy link
Author

 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.

@kavilla kavilla removed the untriaged label Aug 6, 2024
@kavilla kavilla self-assigned this Aug 6, 2024
@Siddhesh-Shinde
Copy link
Author

When I ran the command yarn build --skip-os-packages on my local system (MacBook Pro), I encountered errors. To troubleshoot, I decided to try running the command on a Linux machine. I cloned my code onto a Linux VM and executed yarn build-platform --linux, which worked successfully.

For any Mac users/anyone else out there facing this issue, I recommend setting up the codebase on a Linux VM and running the build command there. This solution worked for me, and it should hopefully resolve the issue for you as well.

Next you need to build the plugin as a .zip file and then install it to your OpenSearch Dashboard distribution

You can follow the steps below for it:

cd plugins/yourplugin

# This command will ask you for OS Dashboard version you are using or tying to install your plugin with
yarn build

cd ../..
cd build/opensearch-dashboards-{OS Dashboard version}-SNAPSHOT-linux-x64
./bin/opensearch-dashboards-plugin install file://{/path/to/your/plugin.zip}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants