Skip to content

Commit bc3d113

Browse files
committed
Install NPM in the EC2 if it's installed yet.
1 parent 7b9d983 commit bc3d113

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

deploy/remote_deploy.sh

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ EOSCRIPT
3939
FRONTEND_PATH="${APP_DIR}/${FRONTEND_DIR}"
4040
FRONTEND_BUILD_DIR="${FRONTEND_PATH}/dist/public"
4141

42-
if [ -d "${FRONTEND_PATH}" ]; then
42+
# Check if we have prebuilt assets already
43+
if [ -d "${FRONTEND_BUILD_DIR}" ]; then
44+
echo "Found prebuilt frontend assets at ${FRONTEND_BUILD_DIR}."
45+
echo "Skipping npm build since assets are already present."
46+
chown -R "${APP_USER}:${APP_USER}" "${FRONTEND_PATH}" 2>/dev/null || true
47+
elif [ -d "${FRONTEND_PATH}" ]; then
48+
# Frontend source exists but no built assets, need to build
4349
if ! command -v "${NPM_BIN}" >/dev/null 2>&1; then
4450
echo "Error: npm command '${NPM_BIN}' not found. Install Node.js/npm or set NPM_BIN." >&2
4551
exit 1
@@ -58,16 +64,9 @@ if [ -d "${FRONTEND_PATH}" ]; then
5864

5965
chown -R "${APP_USER}:${APP_USER}" "${FRONTEND_PATH}"
6066
else
61-
# If the source directory is missing, fall back to an already built bundle
62-
PREBUILT_DIST="${APP_DIR}/CosmoView/dist/public"
63-
if [ -d "${PREBUILT_DIST}" ]; then
64-
echo "Frontend source directory not found. Using existing assets at ${PREBUILT_DIST}."
65-
FRONTEND_BUILD_DIR="${PREBUILT_DIST}"
66-
else
67-
echo "Error: Frontend directory ${FRONTEND_PATH} not found and no prebuilt assets present." >&2
68-
echo "Ensure the CosmoView frontend is built before deployment or set FRONTEND_DIR." >&2
69-
exit 1
70-
fi
67+
echo "Error: Frontend directory ${FRONTEND_PATH} not found and no prebuilt assets present." >&2
68+
echo "Ensure the CosmoView frontend is built before deployment or set FRONTEND_DIR." >&2
69+
exit 1
7170
fi
7271

7372
# Apply capability for port binding if needed (for systemd < 229)

0 commit comments

Comments
 (0)