Self-Hosted Deployment
Learn how to deploy your Motia project to production using motia-docker
Run your Motia app in Docker containers. Same environment everywhere - dev, staging, production.
Example Project: Follow along with the Todo App example - a complete deployment-ready Motia app with Redis configuration.
Quick Start
Important: Run these commands from your project root (where your package.json is).
Getting ENOENT: no such file or directory, open package.json?
You're not in your project directory. Run cd /path/to/your/project first.
Manual Docker Setup
Want more control? Build it yourself.
The docker setup command creates a Dockerfile for you, but here's what's in it:
Python Steps?
If you have Python steps, uncomment this line in the Dockerfile:
And make sure you have a requirements.txt file in your project.
.dockerignore
Create a .dockerignore file to keep your image small:
Build and Run Manually
Build your image
Run it
Open http://localhost:3000 - your app should be running!
Troubleshooting
Using Minimal Docker Images (node:24-slim)
If you're using a minimal Docker image like node:24-slim instead of the official motiadev/motia:latest image, you may encounter errors when creating a new Motia project or running motia dev,
because the redis-memory-server package may require build tools (make, gcc, etc.) to compile Redis from source. These are not included in minimal images.
Solution: Install the required dependencies before running Motia:
Alternative: Install Redis system package to avoid compilation:
Recommended: Use the official motiadev/motia:latest image which includes all required dependencies, or use the full node:24 image instead of node:24-slim.
Deploy to Cloud
Once you have Docker working locally, deploy to any cloud platform:
Railway
The easiest option. Railway detects your Dockerfile automatically and provides managed Redis.
👉 Full Railway deployment guide →
Fly.io
Global edge deployment with Upstash Redis. Great for low-latency worldwide.
👉 Full Fly.io deployment guide →
AWS Lightsail
Lightsail needs ARM. Update your Dockerfile:
Then build and deploy.
Render
Create a Web Service, point to your repo. Render builds automatically. Add a Redis instance and set REDIS_URL.
Configuring Redis for Production
When deploying to production or running multiple Motia instances, you need to configure Redis for shared state, events, and streams.
When to Use External Redis
Use in-memory Redis (default) when:
- Running a single Motia instance
- Development and testing
- Simple deployments
Use external Redis when:
- Running multiple Motia instances (horizontal scaling)
- Production deployments requiring high availability
- Need shared state/events/streams across instances
Docker Compose with Redis
For production deployments, use Docker Compose to run Motia with Redis:
Key features of this setup:
- Healthcheck ensures Redis is ready before Motia starts
REDIS_URLformat works across all platforms (Docker, Railway, Fly.io)USE_REDIS=trueexplicitly enables Redis adapters- No RabbitMQ needed - BullMQ handles events using Redis
Configure Redis in motia.config.ts
Option 1: Simple Redis Config (Recommended)
Use Motia's built-in redis configuration option:
Local vs Production: Set USE_REDIS=true in your docker-compose.yml for production. Without it, Motia uses the built-in in-memory Redis (great for local development).
Option 2: Custom Adapters (Advanced)
For more control, configure adapters manually:
Test Your Setup
Run Docker Compose and verify everything works:
This same Docker Compose setup works as a foundation for deploying to any platform. Just push to Railway, Fly.io, or your own server and configure the REDIS_URL environment variable.
Scaling Multiple Instances
With Redis configured, you can scale to multiple instances:
All instances share the same state, events, and streams through Redis. Put a load balancer in front and requests get distributed across all instances.
Without Redis configuration, each Motia instance has isolated state and events. Configure Redis for multi-instance deployments.
Resources
- Docker Hub - Official Motia image
- Example Project - Full deployment example
- CLI Reference - All docker commands