PromucFlow_constructor/app/rts/build.sh
ChandanBalajiBP 88da94abe7
fix: Remove devDependencies from RTS build (#22239)
Remove devDependencies from the RTS build.
In process of building RTS, we used to copy node_modules to /dist
(Build folder)
But this is not ideal process which increases the build size by adding
unwanted packages.
Now as part of the solution, we are only moving only prodDependencies
to /dist.
This also resolves user request to exclude vulnerable package -
`formidable`.

Fixes #22182
2023-04-13 17:32:13 +05:30

23 lines
936 B
Bash
Executable File

#!/usr/bin/env bash
set -o errexit
cd "$(dirname "$0")"
rm -rf dist/
# This is required for the first time build as node_modules is not present in the image
yarn install --frozen-lockfile
npx tsc && npx tsc-alias
# Keep copy of all dependencies in node_modules_bkp
mv node_modules node_modules_bkp
# Install only production dependencies
yarn install --production --frozen-lockfile
# Copying node_modules directory into dist as rts server requires production dependencies to run server build properly.
# This was previously being done in dockerfile which was copying the symlinks to image rather than the whole directory of shared modules (e.g. AST)
# Also, we copy node_modules with -L flag in order to follow the symlinks for @shared folder and copy the contents instead of just the symlink
cp -RL node_modules ./dist
# Delete production dependencies
rm -rf node_modules
# Restore all dependencies
mv node_modules_bkp node_modules