mcloud-local

โดย medusajs

Execute mcloud local build to reproduce a Cloud build on the local machine. Use when debugging a build-failed deployment without pushing to the tracked branch,…

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

Skills เพิ่มเติมจาก medusajs

mcloud-variables
medusajs
ดำเนินการคำสั่ง mcloud variables เพื่อแสดงรายการและรับตัวแปรสภาพแวดล้อมสำหรับสภาพแวดล้อมคลาวด์ ใช้เมื่อตรวจสอบ อ่าน หรือส่งออกสภาพแวดล้อม…
official
building-storefronts
medusajs
การผสานรวมฟรอนต์เอนด์แบบ SDK-first สำหรับร้านค้า Medusa ด้วยรูปแบบ React Query และกฎการเรียก API ที่สำคัญ ใช้ Medusa JS SDK สำหรับคำขอ API ทั้งหมดเสมอ—ห้ามใช้ fetch() ปกติเด็ดขาด เนื่องจากขาดส่วนหัวที่จำเป็น (publishable API key สำหรับเส้นทางร้านค้า, auth สำหรับเส้นทางผู้ดูแลระบบ) ส่งออบเจกต์ JavaScript ธรรมดาไปยังเมธอดของ SDK ห้ามใช้ JSON.stringify() กับพารามิเตอร์ body เพราะ SDK จัดการการทำให้เป็นอนุกรมโดยอัตโนมัติ ใช้ useQuery สำหรับคำขอ GET และ useMutation สำหรับคำขอ POST/DELETE,...
official
building-admin-dashboard-customizations
medusajs
ส่วนขยาย UI แบบกำหนดเองสำหรับแดชบอร์ด Medusa Admin โดยใช้ Admin SDK และคอมโพเนนต์ Medusa UI โหลดสกิลนี้ก่อนสำหรับงาน UI ของแอดมิน (การวางแผน การนำไปใช้ การสำรวจ); เซิร์ฟเวอร์ MCP ให้เฉพาะการอ้างอิง API เท่านั้น ไม่ใช่รูปแบบการออกแบบหรือกลยุทธ์การโหลดข้อมูล สำคัญ: ใช้ Medusa JS SDK สำหรับคำขอ API ทั้งหมดเสมอ (ห้ามใช้ fetch ปกติ); แยกคิวรีการแสดงผลออกจากคิวรีโมดอล และล้างข้อมูลการแสดงผลหลังจากการกลายพันธุ์ นำวิดเจ็ตไปใช้บนหน้าที่มีอยู่หรือสร้างเส้นทาง UI แบบกำหนดเอง;...
official
learning-medusa
medusajs
ค่ายฝึกพัฒนา Medusa แบบโต้ตอบทีละขั้นตอน ที่คุณจะสร้างฟีเจอร์แบรนด์ไปพร้อมกับเรียนรู้รูปแบบสถาปัตยกรรม ประกอบด้วยสามบทเรียนแบบต่อเนื่อง (รวม 2–3 ชั่วโมง) ครอบคลุมโมดูล เวิร์กโฟลว์ เส้นทาง API การเชื่อมโยงโมดูล ฮุคของเวิร์กโฟลว์ และการปรับแต่ง UI ของแอดมิน มีการตรวจสอบจุดเช็คพอยต์หลังจากแต่ละองค์ประกอบหลัก เพื่อทดสอบความเข้าใจเชิงแนวคิด คุณภาพโค้ด และฟังก์ชันการทำงานก่อนดำเนินการต่อ ปฏิบัติต่อข้อผิดพลาดเป็นโอกาสในการสอน แก้ไขข้อบกพร่องร่วมกันด้วยคำถามวินิจฉัยและการวิเคราะห์สาเหตุที่แท้จริง...
official
db-migrate
medusajs
ดำเนินการย้ายฐานข้อมูล Medusa ที่รออยู่และรายงานผลลัพธ์ รัน npx medusa db:migrate ผ่าน Bash เพื่อใช้การย้ายข้อมูลที่รออยู่ทั้งหมดไปยังฐานข้อมูล Medusa ของคุณ รายงานผลลัพธ์การย้ายข้อมูล รวมถึงจำนวนการย้ายข้อมูลที่ถูกนำไปใช้ ข้อผิดพลาดที่พบ และการยืนยันความสำเร็จ ออกแบบมาสำหรับโปรเจกต์ Medusa ที่มีการตั้งค่า npm/npx มาตรฐาน
official
mcloud-environments
medusajs
ดำเนินการคำสั่ง mcloud environments เพื่อแสดงรายการ รับข้อมูล สร้าง ลบ ปรับใช้ใหม่ หรือเรียกใช้บิลด์สำหรับสภาพแวดล้อม Cloud ใช้เมื่อจัดการวงจรชีวิตของสภาพแวดล้อม...
official
db-generate
medusajs
สร้างการย้ายฐานข้อมูลสำหรับโมดูล Medusa ด้วยคำสั่งเดียว ครอบคลุมคำสั่ง CLI npx medusa db:generate เพื่อสร้างไฟล์การย้ายสำหรับโมดูล Medusa ที่ระบุ รับชื่อโมดูลเป็นอาร์กิวเมนต์และรายงานตำแหน่งไฟล์การย้าย ข้อผิดพลาด และขั้นตอนถัดไป แนะนำให้รัน npx medusa db:migrate หลังจากสร้างเพื่อใช้การย้ายโดยอัตโนมัติ
official
mcloud-deployments
medusajs
Execute mcloud deployments commands to list deployments, retrieve deployment details, and fetch build logs. Use when listing deployments, checking deployment…
official