Reputation: 33
I have built a plugin on top of Opensearch dashboards and I want to containerize the whole application now, and I m not sure how to do it. I intend to create production build of whole application. I found few resources but nothing helped me.
Resources I have explored:
The moment I run yarn build --skip-os-packages
I get a bunch of errors on my local system, which doesn't allow me to create a production build/artifact of Opensearch Dashboard.
yarn run v1.22.22
$ scripts/use_node scripts/build
Browserslist: caniuse-lite is outdated. Please run:
npx update-browserslist-db@latest
Why you should do it regularly: https://github.com/browserslist/update-db#readme
info [ global ] Verifying environment meets requirements
│ succ Node.js version verified
│ succ ✓ 0 sec
info [ global ] Cleaning artifacts from previous builds
│ debg Deleting patterns: []
│ debg Deleted 0 files/directories
│ succ ✓ 0 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
│ERROR failure 0 sec
│ERROR Error: self-signed certificate in certificate chain
│ at Function.AxiosError.from (/Users/siddhesh.shinde/node_modules/axios/lib/core/AxiosError.js:86:14)
│ at RedirectableRequest.handleRequestError (/Users/siddhesh.shinde/node_modules/axios/lib/adapters/http.js:391:25)
│ at RedirectableRequest.emit (node:events:517:28)
│ at ClientRequest.eventHandlers.<computed> (/Users/siddhesh.shinde/node_modules/follow-redirects/index.js:38:24)
│ at ClientRequest.emit (node:events:517:28)
│ at TLSSocket.socketErrorListener (node:_http_client:501:9)
│ at TLSSocket.emit (node:events:517:28)
│ at emitErrorNT (node:internal/streams/destroy:151:8)
│ at emitErrorCloseNT (node:internal/streams/destroy:116:3)
│ at processTicksAndRejections (node:internal/process/task_queues:82:21)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Setting export NODE_TLS_REJECT_UNAUTHORIZED=0 didn't work as well.
Upvotes: 0
Views: 41
Reputation: 33
You can refer to my answer here at Opensearch forum: https://forum.opensearch.org/t/how-to-create-react-production-build-of-opensearch-dashboard/20606
I am also posting the Dockerfile here to give you a clear idea on how to containerize the production build of Opensearch Dashboards
### LAYER 1 : Base Image
FROM node:18.19.0
### LAYER 2
# Create a new user and group
RUN groupadd -r opensearch-dashboards && useradd -r -g opensearch-dashboards osd-user
### LAYER 3
# Set the working directory
WORKDIR /home/osd-user/workdir
### LAYER 4
# Copy application code into the container
COPY . .
### LAYER 5
# Create yarnrc file and grant ownership to non root user
RUN touch /home/osd-user/.yarnrc && \
chown -R osd-user:opensearch-dashboards /home/osd-user
# Switch to non root user
USER osd-user
### LAYER 6
# Bootstrap OpenSearch Dashboards
RUN yarn config set strict-ssl false && \
export NODE_TLS_REJECT_UNAUTHORIZED=0 && \
export NO_PROXY=localhost && \
yarn osd bootstrap
### LAYER 7
# Build OSD artifact
RUN export NODE_TLS_REJECT_UNAUTHORIZED=1 && yarn build-platform —linux
# Expose application port
EXPOSE 5601
### LAYER 8
# Build xyz plugin, install xyz plugin
RUN cd plugins/xyz && \
yes "2.13.0" | yarn build && \
cd ../.. && \
cd build/opensearch-dashboards-2.13.0-SNAPSHOT-linux-x64 && \
./bin/opensearch-dashboards-plugin remove xyz && \
./bin/opensearch-dashboards-plugin install file:///home/osd-user/workdir/plugins/xyz/build/xyz-2.13.0.zip
# Start Server
WORKDIR /home/osd-user/workdir/build/opensearch-dashboards-2.13.0-SNAPSHOT-linux-x64/bin
CMD ["./opensearch-dashboards"]
Upvotes: 0