Skip to main content

Self-Hosted Deployment

We provide a docker image that you can use to deploy your Motia project to production. You can use it as a base image and add your own customizations or use it as is.

You will need to use the latest version of the motia package 0.5.2-beta.101 or higher

Quick setup

#### Setup your motia project
npx motia@latest docker setup
#### Run your motia project inside a container
npx motia@latest docker run
#### You are good to go, your project should be running on localhost under port 3000, for additional options and configuration run
npx motia@latest docker run --help

Reference the CLI for more information on the docker commands.

Using the docker image

You will need to implement your own Dockerfile where you will use the motia-docker image as a base image. Use the following template as a starting point for your Dockerfile:

# NOTE: Some cloud providers will require you to specify the platform to match your target architecture
# i.e.: AWS Lightsail requires arm64, therefore you update your FROM statement to: FROM --platform=linux/arm64 motiadev/motia:latest
FROM motiadev/motia:latest

# Install Dependencies
COPY package*.json ./
RUN npm ci --only=production

# Move application files
COPY . .

# Enable the following lines if you are using python steps!!!
# Setup python steps dependencies
# RUN npx motia@latest install

# Expose outside access to the motia project
EXPOSE 3000

# Run your application
CMD ["npm", "run", "start"]
Depending on the cloud provider you will use to deploy your Motia project, you will need to adjust the exposed ports and the command to start your application.

Create a .dockerignore file

Create a .dockerignore file in the root of your project to exclude files that are not needed in the docker image. You can use the following template as a starting point for your .dockerignore file:

# Git
.git
.gitignore

# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
env/
venv/
ENV/

# Node
node_modules/
npm-debug.log
yarn-debug.log
yarn-error.log

# IDE
.vscode/
.idea/
*.swp
*.swo

# Local development
.env

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

Build your image

docker build -t <your-image-name> .

Run your Motia application

Once you've built your image, you can run it using the following command:

docker run -it --rm -p 3000:3000 <your-image-name>

Motia Docker Resources