From medusa-commerce
Guides Medusa v2 production deployment: build process, server vs worker modes, PostgreSQL/Redis config, environment variables, and checklists.
npx claudepluginhub orcaqubits/agentic-commerce-skills-plugins --plugin medusa-commerceThis skill is limited to using the following tools:
**Fetch live docs**:
Generates design tokens/docs from CSS/Tailwind/styled-components codebases, audits visual consistency across 10 dimensions, detects AI slop in UI.
Records polished WebM UI demo videos of web apps using Playwright with cursor overlay, natural pacing, and three-phase scripting. Activates for demo, walkthrough, screen recording, or tutorial requests.
Delivers idiomatic Kotlin patterns for null safety, immutability, sealed classes, coroutines, Flows, extensions, DSL builders, and Gradle DSL. Use when writing, reviewing, refactoring, or designing Kotlin code.
Fetch live docs:
site:docs.medusajs.com deployment production for production deployment guidessite:docs.medusajs.com medusa build for build process detailshttps://docs.medusajs.com/learn/fundamentals/cli for CLI command referencesite:docs.medusajs.com environment variables configuration for env var referencesite:docs.medusajs.com redis cache events for Redis caching and event bus setup| 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.
.medusa/
├── server/ — Compiled server code
│ ├── src/ — Custom modules, routes, workflows
│ └── medusa-config.js
└── admin/ — Bundled admin dashboard (static)
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) |
| 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 |
| 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 |
?sslmode=require to DATABASE_URL# Generate migration after DML model changes
npx medusa db:generate <module_name>
# Apply migrations
npx medusa db:migrate
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
maxmemory and eviction policies for cache| 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) |
# 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.
NODE_ENV=productionCOOKIE_SECRET and JWT_SECRETDATABASE_URL with SSL mode enabledREDIS_URL for events, cache, and worker queueSTORE_CORS, ADMIN_CORS, AUTH_CORS)npx medusa build successfullynpx medusa db:migrate against production database--max-old-space-size for Node.js memory limitsFetch the Medusa deployment documentation for exact build flags, Docker configuration, and platform-specific deployment guides before deploying.