@@ -37,29 +37,38 @@ EOSCRIPT
3737
3838# Build the frontend bundle
3939FRONTEND_PATH=" ${APP_DIR} /${FRONTEND_DIR} "
40- if [ ! -d " ${FRONTEND_PATH} " ]; then
41- echo " Error: Frontend directory ${FRONTEND_PATH} not found."
42- exit 1
43- fi
40+ FRONTEND_BUILD_DIR=" ${FRONTEND_PATH} /dist/public"
4441
45- if ! command -v " ${NPM_BIN} " > /dev/null 2>&1 ; then
46- echo " Error: npm command '${NPM_BIN} ' not found. Install Node.js/npm or set NPM_BIN." >&2
47- exit 1
48- fi
42+ if [ -d " ${FRONTEND_PATH} " ]; then
43+ if ! command -v " ${NPM_BIN} " > /dev/null 2>&1 ; then
44+ echo " Error: npm command '${NPM_BIN} ' not found. Install Node.js/npm or set NPM_BIN." >&2
45+ exit 1
46+ fi
4947
50- echo " Installing frontend dependencies with ${NPM_BIN} ..."
51- sudo -u " ${APP_USER} " bash -c " cd '${FRONTEND_PATH} ' && ${NPM_BIN} install"
48+ echo " Installing frontend dependencies with ${NPM_BIN} ..."
49+ sudo -u " ${APP_USER} " bash -c " cd '${FRONTEND_PATH} ' && ${NPM_BIN} install"
5250
53- echo " Building frontend production bundle..."
54- sudo -u " ${APP_USER} " bash -c " cd '${FRONTEND_PATH} ' && ${NPM_BIN} run build"
51+ echo " Building frontend production bundle..."
52+ sudo -u " ${APP_USER} " bash -c " cd '${FRONTEND_PATH} ' && ${NPM_BIN} run build"
5553
56- FRONTEND_BUILD_DIR=" ${FRONTEND_PATH} /dist/public"
57- if [ ! -d " ${FRONTEND_BUILD_DIR} " ]; then
58- echo " Error: Frontend build directory ${FRONTEND_BUILD_DIR} was not created." >&2
59- exit 1
60- fi
54+ if [ ! -d " ${FRONTEND_BUILD_DIR} " ]; then
55+ echo " Error: Frontend build directory ${FRONTEND_BUILD_DIR} was not created." >&2
56+ exit 1
57+ fi
6158
62- chown -R " ${APP_USER} :${APP_USER} " " ${FRONTEND_PATH} "
59+ chown -R " ${APP_USER} :${APP_USER} " " ${FRONTEND_PATH} "
60+ 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
71+ fi
6372
6473# Apply capability for port binding if needed (for systemd < 229)
6574# Modern systemd (>= 229) uses AmbientCapabilities in the service file
0 commit comments