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.
Quick setup
npx motia@latest docker setup
npx motia@latest docker 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"]
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>