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"]