From d707cdf8507006393598fcbc28fa8d8b6df63e46 Mon Sep 17 00:00:00 2001 From: chan Date: Fri, 5 Jun 2026 08:58:18 +0900 Subject: [PATCH] fix(deploy): resolve frontend deployment failure by fixing workspace detection and dependency installation --- adminfront/Dockerfile | 3 ++- adminfront/scripts/runtime-mode.sh | 41 ++++++++++++++++++++---------- devfront/Dockerfile | 3 ++- devfront/scripts/runtime-mode.sh | 41 ++++++++++++++++++++---------- orgfront/Dockerfile | 3 ++- orgfront/scripts/runtime-mode.sh | 41 ++++++++++++++++++++---------- 6 files changed, 87 insertions(+), 45 deletions(-) diff --git a/adminfront/Dockerfile b/adminfront/Dockerfile index 5f555614..876dbc57 100644 --- a/adminfront/Dockerfile +++ b/adminfront/Dockerfile @@ -9,11 +9,12 @@ ENV CI=true RUN corepack enable && corepack prepare pnpm@10.5.2 --activate # Copy workspace configs and common package +COPY pnpm-workspace.yaml pnpm-lock.yaml ./ COPY common ./common COPY adminfront ./adminfront # Install dependencies for the workspace -RUN cd common && pnpm install --no-frozen-lockfile --ignore-scripts +RUN pnpm install --filter adminfront... --filter baron-sso... --no-frozen-lockfile --ignore-scripts # 프로덕션 서빙을 위한 serve 패키지 글로벌 설치 RUN npm install -g serve diff --git a/adminfront/scripts/runtime-mode.sh b/adminfront/scripts/runtime-mode.sh index c70cf241..b2709aa1 100644 --- a/adminfront/scripts/runtime-mode.sh +++ b/adminfront/scripts/runtime-mode.sh @@ -36,15 +36,30 @@ if [ "${1:-}" = "--print-mode" ]; then fi ensure_frontend_dependencies() { - APP_WORKSPACE_FILTER="../adminfront" + APP_PACKAGE_NAME="adminfront" - # If common workspace exists, manage dependencies from the real workspace tree. - if [ -d /workspace/common ] && [ -f /workspace/common/package.json ]; then - WORKSPACE_DIR="/workspace/common" - LOCK_FILE="/workspace/common/pnpm-lock.yaml" + # Detect workspace root + if [ -f "/workspace/pnpm-workspace.yaml" ]; then + WORKSPACE_ROOT="/workspace" + elif [ -f "../../pnpm-workspace.yaml" ]; then + WORKSPACE_ROOT="../.." + else + WORKSPACE_ROOT="" + fi + + # Manage dependencies from the real workspace tree if possible, otherwise use current dir. + if [ -n "$WORKSPACE_ROOT" ]; then + WORKSPACE_DIR="$WORKSPACE_ROOT" + LOCK_FILE="$WORKSPACE_ROOT/pnpm-lock.yaml" + INSTALL_CMD="cd $WORKSPACE_ROOT && CI=true pnpm install --filter ${APP_PACKAGE_NAME}... --frozen-lockfile --ignore-scripts" + elif [ -f "pnpm-lock.yaml" ]; then + WORKSPACE_DIR="." + LOCK_FILE="pnpm-lock.yaml" + INSTALL_CMD="CI=true pnpm install --frozen-lockfile --ignore-scripts" else WORKSPACE_DIR="." LOCK_FILE="package-lock.json" + INSTALL_CMD="npm ci" fi if [ ! -f "$WORKSPACE_DIR/package.json" ]; then @@ -85,9 +100,9 @@ ensure_frontend_dependencies() { } if command -v sha256sum >/dev/null 2>&1; then - deps_hash="$(sha256sum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" 2>/dev/null | sha256sum | awk '{print $1}')" + deps_hash="$(sha256sum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" package.json 2>/dev/null | sha256sum | awk '{print $1}')" else - deps_hash="$(cksum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" 2>/dev/null | cksum | awk '{print $1}')" + deps_hash="$(cksum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" package.json 2>/dev/null | cksum | awk '{print $1}')" fi deps_stamp="node_modules/.baron-deps-hash" installed_hash="$(cat "$deps_stamp" 2>/dev/null || true)" @@ -96,20 +111,18 @@ ensure_frontend_dependencies() { echo "Installing frontend dependencies..." acquire_install_lock if command -v sha256sum >/dev/null 2>&1; then - deps_hash="$(sha256sum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" 2>/dev/null | sha256sum | awk '{print $1}')" + deps_hash="$(sha256sum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" package.json 2>/dev/null | sha256sum | awk '{print $1}')" else - deps_hash="$(cksum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" 2>/dev/null | cksum | awk '{print $1}')" + deps_hash="$(cksum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" package.json 2>/dev/null | cksum | awk '{print $1}')" fi installed_hash="$(cat "$deps_stamp" 2>/dev/null || true)" if [ "$installed_hash" = "$deps_hash" ]; then release_install_lock return 0 fi - if [ "$WORKSPACE_DIR" = "/workspace/common" ]; then - (cd /workspace/common && CI=true pnpm install --filter "${APP_WORKSPACE_FILTER}..." --frozen-lockfile --ignore-scripts) - else - npm ci - fi + + eval "$INSTALL_CMD" + mkdir -p node_modules printf '%s\n' "$deps_hash" > "$deps_stamp" release_install_lock diff --git a/devfront/Dockerfile b/devfront/Dockerfile index c18fed5b..e9d8d763 100644 --- a/devfront/Dockerfile +++ b/devfront/Dockerfile @@ -9,11 +9,12 @@ ENV CI=true RUN corepack enable && corepack prepare pnpm@10.5.2 --activate # Copy workspace configs and common package +COPY pnpm-workspace.yaml pnpm-lock.yaml ./ COPY common ./common COPY devfront ./devfront # Install dependencies for the workspace -RUN cd common && pnpm install --no-frozen-lockfile --ignore-scripts +RUN pnpm install --filter devfront... --filter baron-sso... --no-frozen-lockfile --ignore-scripts # 프로덕션 서빙을 위한 serve 패키지 글로벌 설치 RUN npm install -g serve diff --git a/devfront/scripts/runtime-mode.sh b/devfront/scripts/runtime-mode.sh index 5374b8ff..770d3671 100644 --- a/devfront/scripts/runtime-mode.sh +++ b/devfront/scripts/runtime-mode.sh @@ -36,15 +36,30 @@ if [ "${1:-}" = "--print-mode" ]; then fi ensure_frontend_dependencies() { - APP_WORKSPACE_FILTER="../devfront" + APP_PACKAGE_NAME="devfront" - # If common workspace exists, manage dependencies from the real workspace tree. - if [ -d /workspace/common ] && [ -f /workspace/common/package.json ]; then - WORKSPACE_DIR="/workspace/common" - LOCK_FILE="/workspace/common/pnpm-lock.yaml" + # Detect workspace root + if [ -f "/workspace/pnpm-workspace.yaml" ]; then + WORKSPACE_ROOT="/workspace" + elif [ -f "../../pnpm-workspace.yaml" ]; then + WORKSPACE_ROOT="../.." + else + WORKSPACE_ROOT="" + fi + + # Manage dependencies from the real workspace tree if possible, otherwise use current dir. + if [ -n "$WORKSPACE_ROOT" ]; then + WORKSPACE_DIR="$WORKSPACE_ROOT" + LOCK_FILE="$WORKSPACE_ROOT/pnpm-lock.yaml" + INSTALL_CMD="cd $WORKSPACE_ROOT && CI=true pnpm install --filter ${APP_PACKAGE_NAME}... --frozen-lockfile --ignore-scripts" + elif [ -f "pnpm-lock.yaml" ]; then + WORKSPACE_DIR="." + LOCK_FILE="pnpm-lock.yaml" + INSTALL_CMD="CI=true pnpm install --frozen-lockfile --ignore-scripts" else WORKSPACE_DIR="." LOCK_FILE="package-lock.json" + INSTALL_CMD="npm ci" fi if [ ! -f "$WORKSPACE_DIR/package.json" ]; then @@ -85,9 +100,9 @@ ensure_frontend_dependencies() { } if command -v sha256sum >/dev/null 2>&1; then - deps_hash="$(sha256sum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" 2>/dev/null | sha256sum | awk '{print $1}')" + deps_hash="$(sha256sum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" package.json 2>/dev/null | sha256sum | awk '{print $1}')" else - deps_hash="$(cksum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" 2>/dev/null | cksum | awk '{print $1}')" + deps_hash="$(cksum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" package.json 2>/dev/null | cksum | awk '{print $1}')" fi deps_stamp="node_modules/.baron-deps-hash" installed_hash="$(cat "$deps_stamp" 2>/dev/null || true)" @@ -96,20 +111,18 @@ ensure_frontend_dependencies() { echo "Installing frontend dependencies..." acquire_install_lock if command -v sha256sum >/dev/null 2>&1; then - deps_hash="$(sha256sum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" 2>/dev/null | sha256sum | awk '{print $1}')" + deps_hash="$(sha256sum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" package.json 2>/dev/null | sha256sum | awk '{print $1}')" else - deps_hash="$(cksum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" 2>/dev/null | cksum | awk '{print $1}')" + deps_hash="$(cksum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" package.json 2>/dev/null | cksum | awk '{print $1}')" fi installed_hash="$(cat "$deps_stamp" 2>/dev/null || true)" if [ "$installed_hash" = "$deps_hash" ]; then release_install_lock return 0 fi - if [ "$WORKSPACE_DIR" = "/workspace/common" ]; then - (cd /workspace/common && CI=true pnpm install --filter "${APP_WORKSPACE_FILTER}..." --frozen-lockfile --ignore-scripts) - else - npm ci - fi + + eval "$INSTALL_CMD" + mkdir -p node_modules printf '%s\n' "$deps_hash" > "$deps_stamp" release_install_lock diff --git a/orgfront/Dockerfile b/orgfront/Dockerfile index aaa6290e..c5f6d107 100644 --- a/orgfront/Dockerfile +++ b/orgfront/Dockerfile @@ -9,11 +9,12 @@ ENV CI=true RUN corepack enable && corepack prepare pnpm@10.5.2 --activate # Copy workspace configs and common package +COPY pnpm-workspace.yaml pnpm-lock.yaml ./ COPY common ./common COPY orgfront ./orgfront # Install dependencies for the workspace -RUN cd common && pnpm install --no-frozen-lockfile --ignore-scripts +RUN pnpm install --filter orgfront... --filter baron-sso... --no-frozen-lockfile --ignore-scripts # 프로덕션 서빙을 위한 serve 패키지 글로벌 설치 RUN npm install -g serve diff --git a/orgfront/scripts/runtime-mode.sh b/orgfront/scripts/runtime-mode.sh index 4c3bb88a..5c7f6bff 100644 --- a/orgfront/scripts/runtime-mode.sh +++ b/orgfront/scripts/runtime-mode.sh @@ -36,15 +36,30 @@ if [ "${1:-}" = "--print-mode" ]; then fi ensure_frontend_dependencies() { - APP_WORKSPACE_FILTER="../orgfront" + APP_PACKAGE_NAME="orgfront" - # If common workspace exists, manage dependencies from the real workspace tree. - if [ -d /workspace/common ] && [ -f /workspace/common/package.json ]; then - WORKSPACE_DIR="/workspace/common" - LOCK_FILE="/workspace/common/pnpm-lock.yaml" + # Detect workspace root + if [ -f "/workspace/pnpm-workspace.yaml" ]; then + WORKSPACE_ROOT="/workspace" + elif [ -f "../../pnpm-workspace.yaml" ]; then + WORKSPACE_ROOT="../.." + else + WORKSPACE_ROOT="" + fi + + # Manage dependencies from the real workspace tree if possible, otherwise use current dir. + if [ -n "$WORKSPACE_ROOT" ]; then + WORKSPACE_DIR="$WORKSPACE_ROOT" + LOCK_FILE="$WORKSPACE_ROOT/pnpm-lock.yaml" + INSTALL_CMD="cd $WORKSPACE_ROOT && CI=true pnpm install --filter ${APP_PACKAGE_NAME}... --frozen-lockfile --ignore-scripts" + elif [ -f "pnpm-lock.yaml" ]; then + WORKSPACE_DIR="." + LOCK_FILE="pnpm-lock.yaml" + INSTALL_CMD="CI=true pnpm install --frozen-lockfile --ignore-scripts" else WORKSPACE_DIR="." LOCK_FILE="package-lock.json" + INSTALL_CMD="npm ci" fi if [ ! -f "$WORKSPACE_DIR/package.json" ]; then @@ -85,9 +100,9 @@ ensure_frontend_dependencies() { } if command -v sha256sum >/dev/null 2>&1; then - deps_hash="$(sha256sum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" 2>/dev/null | sha256sum | awk '{print $1}')" + deps_hash="$(sha256sum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" package.json 2>/dev/null | sha256sum | awk '{print $1}')" else - deps_hash="$(cksum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" 2>/dev/null | cksum | awk '{print $1}')" + deps_hash="$(cksum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" package.json 2>/dev/null | cksum | awk '{print $1}')" fi deps_stamp="node_modules/.baron-deps-hash" installed_hash="$(cat "$deps_stamp" 2>/dev/null || true)" @@ -96,20 +111,18 @@ ensure_frontend_dependencies() { echo "Installing frontend dependencies..." acquire_install_lock if command -v sha256sum >/dev/null 2>&1; then - deps_hash="$(sha256sum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" 2>/dev/null | sha256sum | awk '{print $1}')" + deps_hash="$(sha256sum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" package.json 2>/dev/null | sha256sum | awk '{print $1}')" else - deps_hash="$(cksum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" 2>/dev/null | cksum | awk '{print $1}')" + deps_hash="$(cksum "$WORKSPACE_DIR/package.json" "$LOCK_FILE" package.json 2>/dev/null | cksum | awk '{print $1}')" fi installed_hash="$(cat "$deps_stamp" 2>/dev/null || true)" if [ "$installed_hash" = "$deps_hash" ]; then release_install_lock return 0 fi - if [ "$WORKSPACE_DIR" = "/workspace/common" ]; then - (cd /workspace/common && CI=true pnpm install --filter "${APP_WORKSPACE_FILTER}..." --frozen-lockfile --ignore-scripts) - else - npm ci - fi + + eval "$INSTALL_CMD" + mkdir -p node_modules printf '%s\n' "$deps_hash" > "$deps_stamp" release_install_lock