Medusa deploy

From OrcaQubits/agentic-commerce-skills-plugins · View interactive version

Medusa deploy is an AI agent skill from the GitHub repository OrcaQubits/agentic-commerce-skills-plugins. Deploy Medusa v2 to production — build process, server vs worker mode, environment variables, hosting options, Redis caching, database configuration, and production checklist. Use when deploying Medusa applications.

How to use this skill

Skill file

Medusa v2 Deployment

Before writing code

Fetch live docs:

  1. Web-search site:docs.medusajs.com deployment production for production deployment guides
  2. Web-search site:docs.medusajs.com medusa build for build process details
  3. Fetch https://docs.medusajs.com/resources/medusa-cli for CLI command reference
  4. Web-search site:docs.medusajs.com environment variables configuration for env var reference
  5. Web-search site:docs.medusajs.com redis cache events for Redis caching and event bus setup

Build Process

Build Commands

| Command | Purpose |

|---------|---------|

| npx medusa build | Compile server + admin dashboard for production |

| npx medusa db:migrate | Run pending database migrations |

| npx medusa start | Start the production server |

| npx medusa worker | Start the background worker process |

The build step compiles TypeScript, bundles admin extensions (Vite), and prepares the .medusa/ output directory.

Build Output Structure

.medusa/
├── server/           — Compiled server code
│   ├── src/          — Custom modules, routes, workflows
│   └── medusa-config.js
└── admin/            — Bundled admin dashboard (static)

Server vs Worker Mode

Medusa v2 supports running the server and background workers as separate processes:

| Mode | Command | Handles |

|------|---------|---------|

| Server | npx medusa start | HTTP requests, API routes, admin dashboard |

| Worker | npx medusa worker | Workflows, scheduled jobs, event subscribers |

| Combined | Default start behavior | Both server and worker (single process) |

When to Separate

Environment Variables

Required Variables

| Variable | Purpose | Example |

|----------|---------|---------|

| DATABASE_URL | PostgreSQL connection string | postgres://user:pass@host:5432/medusa |

| COOKIE_SECRET | Session cookie signing | Random 32+ character string |

| JWT_SECRET | JWT token signing | Random 32+ character string |

| NODE_ENV | Runtime environment | production |

Optional but Recommended

| Variable | Purpose | Default |

|----------|---------|---------|

| REDIS_URL | Redis connection for cache/events/workers | None (in-memory) |

| STORE_CORS | Store API CORS origins | http://localhost:8000 |

| ADMIN_CORS | Admin API CORS origins | http://localhost:9000 |

| AUTH_CORS | Auth route CORS origins | Combination of store + admin |

| PORT | Server listen port | 9000 |

| MEDUSA_ADMIN_ONBOARDING_TYPE | Admin onboarding flow | default |

| MEDUSA_WORKER_MODE | server, worker, or shared | shared |

Database Configuration

PostgreSQL Requirements

Migration Workflow

# Generate migration after DML model changes
npx medusa db:generate <module_name>
# Apply migrations
npx medusa db:migrate

Redis Configuration

Redis serves three roles in production Medusa:

| Role | Purpose | Required? |

|------|---------|-----------|

| Event Bus | Pub/sub for event-driven subscribers | Recommended |

| Cache | Module data caching layer | Recommended |

| Worker Queue | Job queue for background workflows | Required for worker mode |

Configure in medusa-config.ts by registering the Redis modules:

// Fetch live docs for Redis module registration
// in medusa-config.ts modules array

Hosting Options

| Platform | Type | Notes |

|----------|------|-------|

| Railway | PaaS | One-click deploy, managed PostgreSQL and Redis |

| DigitalOcean App Platform | PaaS | Managed infrastructure, auto-scaling |

| AWS (EC2/ECS/Fargate) | IaaS/CaaS | Full control, use with RDS and ElastiCache |

| Google Cloud Run | Serverless containers | Auto-scaling, pay-per-use |

| Render | PaaS | Simple deploy, managed databases |

| Self-hosted (Docker) | Container | Full control, use Docker Compose or Kubernetes |

| Vercel | Serverless | Admin/storefront hosting only (not the Medusa server) |

Docker Deployment

# Fetch live docs for official Medusa Dockerfile
# and docker-compose.yml patterns

A typical Docker Compose setup includes three services: Medusa server, PostgreSQL, and Redis.

Production Checklist

Pre-Deploy

Infrastructure

Post-Deploy

Scaling Strategies

Horizontal Scaling

Vertical Scaling

Best Practices

Fetch the Medusa deployment documentation for exact build flags, Docker configuration, and platform-specific deployment guides before deploying.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.