Harden runtime cleanup in production deploy
This commit is contained in:
@@ -16,16 +16,28 @@ npm run build
|
||||
|
||||
echo "[deploy] Publishing frontend runtime to $FRONTEND_RUNTIME"
|
||||
mkdir -p "$FRONTEND_RUNTIME"
|
||||
find "$FRONTEND_RUNTIME" -mindepth 1 ! -name 'dist' ! -name 'server.js' -exec rm -rf {} +
|
||||
shopt -s dotglob nullglob
|
||||
for item in "$FRONTEND_RUNTIME"/*; do
|
||||
base="$(basename "$item")"
|
||||
if [[ "$base" != "dist" && "$base" != "server.js" ]]; then
|
||||
rm -rf "$item"
|
||||
fi
|
||||
done
|
||||
rm -rf "$FRONTEND_RUNTIME/dist"
|
||||
cp -r dist "$FRONTEND_RUNTIME/"
|
||||
cp server.js "$FRONTEND_RUNTIME/"
|
||||
|
||||
echo "[deploy] Publishing backend runtime to $BACKEND_RUNTIME"
|
||||
mkdir -p "$BACKEND_RUNTIME"
|
||||
find "$BACKEND_RUNTIME" -mindepth 1 ! -name '.env' -exec rm -rf {} +
|
||||
for item in "$BACKEND_RUNTIME"/*; do
|
||||
base="$(basename "$item")"
|
||||
if [[ "$base" != ".env" ]]; then
|
||||
rm -rf "$item"
|
||||
fi
|
||||
done
|
||||
cp -a "$BACKEND_SOURCE"/. "$BACKEND_RUNTIME/"
|
||||
rm -f "$BACKEND_RUNTIME/.env.example"
|
||||
shopt -u dotglob nullglob
|
||||
|
||||
cd "$BACKEND_RUNTIME"
|
||||
npm ci --omit=dev
|
||||
|
||||
Reference in New Issue
Block a user