Skip to content

Commit 07d7d1d

Browse files
committed
Add build dir var for CI/CD workflow.
1 parent e2bb23c commit 07d7d1d

2 files changed

Lines changed: 29 additions & 20 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ pipeline performs the following steps:
8787
4. Creates a dedicated service user (`nasaapp`) if it doesn't exist.
8888
5. Sets proper ownership and permissions for the application directory.
8989
6. Installs Python dependencies in a virtual environment owned by the service user.
90-
7. Installs CosmoView dependencies on the EC2 host and rebuilds the Vite bundle to guarantee fresh
91-
assets.
90+
7. Installs CosmoView dependencies on the EC2 host and rebuilds the Vite bundle (or reuses the
91+
synced `CosmoView/dist/public` assets if the source directory is absent).
9292
8. Applies necessary capabilities to bind to port 80 (if running on a privileged port).
9393
9. Restarts the systemd service or launches Uvicorn as a background process.
9494

deploy/remote_deploy.sh

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,38 @@ EOSCRIPT
3737

3838
# Build the frontend bundle
3939
FRONTEND_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

Comments
 (0)