mcloud-local

작성자: medusajs

로컬 머신에서 Cloud build를 재현하기 위해 mcloud local build를 실행합니다. 추적된 브랜치로 푸시하지 않고 빌드에 실패한 배포를 디버깅할 때 사용합니다,…

npx skills add https://github.com/medusajs/medusa-agent-skills --skill mcloud-local

Cloud CLI: Local Command

Execute mcloud local build to run a Cloud build on the local machine, mirroring how Cloud builds the project. Use it to debug build-failed deployments without pushing changes and waiting for a full Cloud build.

Constraints

  • No --json flag. local build streams plaintext build output and signals the result through its exit code (0 = success). Do not parse its output as JSON.
  • Requires Docker installed and running, and must run from inside the project's Git repository.
  • Reproduces build-failed (build) failures only — not deployment-failed (runtime) failures. For runtime failures, use mcloud logs --deployment <id>.
  • Available since mcloud CLI v0.1.10.
  • The Docker build cache is disabled by default so variable changes always invalidate the cache; pass --docker-cache to enable it.

Command

local build

Run a Cloud build locally. Infers the root path and build variables from the linked Cloud project and environment. Builds the backend by default; pass --type storefront for the storefront.

mcloud local build \
  --organization <org-id> \
  --project <project-id-or-handle> \
  --environment <environment-handle>

Options:

  • -o/--organization <id> — Organization ID (falls back to active context)
  • -p/--project <id-or-handle> — Project ID or handle (falls back to active context)
  • -e/--environment <handle> — Environment whose variables are used (falls back to active context)
  • -t/--type <backend|storefront> — Build type (default: backend)
  • --root-path <path> — Backend root path relative to the repo root (inferred if omitted; . if no Cloud project found)
  • --storefront-path <path> — Storefront path relative to the repo root, for --type storefront (inferred if omitted)
  • --env-file <path> — Use a local .env file instead of the Cloud environment's variables
  • -v/--var <KEY=VALUE> — Override a single build variable; repeatable
  • --docker-cache — Enable the Docker build cache (default: false)

Output:

  • On success (exit 0), the backend image is tagged <repository-name>:cloud-local-build-<commit-hash>; a storefront build writes its output directory and prints the path.
  • On failure (non-zero exit), the command exits with the failing step's error — debug it as you would a Cloud build.

Reproduce a Build Failure

Check out the same commit the failed deployment built so the local build matches, then route on the exit code:

# Identify the failing deployment and the commit it built
DEPLOYMENT_ID=$(
  mcloud deployments list --json \
    | jq -r '[.[] | select(.backend_status == "build-failed")][0].id'
)
COMMIT=$(mcloud deployments get "$DEPLOYMENT_ID" --json | jq -r '.commit_hash')

git checkout "$COMMIT"

if mcloud local build; then
  echo "Build succeeded locally; failure not reproducible from this commit."
else
  echo "Build failed locally; inspect the streamed output for the failing step."
fi

Once the local build exits 0, push the fix to the tracked branch and start a fresh Cloud build with mcloud environments trigger-build <env>.

Examples

# Reproduce the backend build for the active context
mcloud local build

# Reproduce the storefront build
mcloud local build --type storefront --storefront-path apps/storefront

# Test a build-variable fix without editing code
mcloud local build --var NODE_ENV=production

# Build against a local .env file
mcloud local build --env-file .env

# Reuse the Docker cache for a faster rebuild
mcloud local build --docker-cache

medusajs의 다른 스킬

creating-agents-in-medusa
medusajs
Medusa 프로젝트에서 내부 관리자용 AI 에이전트를 구축할 때 사용합니다. 이러한 에이전트는 고객이 아닌 판매자와 스토어 운영자가 사용합니다. 다음을 다룹니다…
reviewing-prs
medusajs
Medusa 저장소의 GitHub 풀 리퀘스트를 검토합니다. PR 템플릿 준수 여부, 기여 가이드라인, 코드 규칙, 보안, 성능 등을 확인합니다…
writing-releases
medusajs
Medusa 릴리스에 대한 GitHub 릴리스 노트를 기존 스타일로 작성합니다. 커밋 및 PR 목록에서 초안 릴리스 설명을 생성할 때 사용합니다…
writing-tsdocs
medusajs
Medusa 코드베이스의 TypeScript 소스 파일에 TypeDoc(TSDoc) 주석을 추가하고 업데이트합니다. HTTP 유형, API 라우트, UI 컴포넌트, 데이터 모델, 서비스…를 다룹니다.
mcloud-variables
medusajs
mcloud variables 명령어를 실행하여 Cloud 환경의 환경 변수를 나열하고 가져옵니다. 환경을 검사하거나 읽거나 내보낼 때 사용합니다.
mcloud-deployments
medusajs
mcloud deployments 명령을 실행하여 배포 목록을 조회하고, 배포 세부 정보를 검색하며, 빌드 로그를 가져옵니다. 배포 목록을 확인하거나, 배포 상태를 점검할 때 사용합니다.
writing-docs
medusajs
Medusa 문서의 book, resources, ui, user-guide, cloud 프로젝트에 대한 MDX 파일을 작성하고 업데이트합니다. 문서 변경 사항을 적용할 때 사용합니다…
building-storefronts
medusajs
SDK 기반의 Medusa 스토어프론트 통합으로, React Query 패턴과 중요한 API 호출 규칙을 포함합니다. 모든 API 요청에는 항상 Medusa JS SDK를 사용해야 하며, 일반 fetch()는 사용하지 않습니다. fetch()는 필수 헤더(스토어 라우트의 publishable API 키, 관리자 라우트의 인증)가 누락되기 때문입니다. SDK 메서드에는 일반 JavaScript 객체를 전달하며, 본문 매개변수에 JSON.stringify()를 사용하지 않습니다. SDK가 자동으로 직렬화를 처리합니다. GET 요청에는 useQuery를, POST/DELETE 요청에는 useMutation을 사용합니다.