Motia Icon
Deployment Guide/Motia Cloud

Deployment

Deploying your project to Motia Cloud

There are two ways to deploy your project to Motia Cloud:

  1. Using the CLI
  2. Using the Web interface

Using the Motia CLI for Deployment

motia cloud deploy --api-key <api-key> --version-name <version> [options]

Required Options

OptionAliasDescriptionEnvironment Variable
--api-key-kAPI key for authenticationMOTIA_API_KEY
--version-name-vVersion tag for the deploymentNone

Optional Options

OptionAliasDescriptionEnvironment Variable
--environment-id-sEnvironment IDMOTIA_ENVIRONMENT_ID
--version-description-dVersion description for the deploymentNone
--env-file-ePath to environment fileNone

Note: Command-line options take precedence over environment variables. If both are provided, the command-line value will be used.

Deploy with a specific version:

motia cloud deploy --api-key your-api-key-here --version-name 1.2.3

Deploy to a specific environment with environment variables:

motia cloud deploy --api-key your-api-key-here \
  --version-name 1.2.3 \
  --env-file .env.production \
  --environment-id env-id

Using Web interface

Through the web interface, you can deploy your project from workbench to a live environment with one click.

One Click Deployment

Steps to deploy from web interface:

  1. Have your local project running (make sure your Motia version is 0.6.4 or higher)
  2. Go to import from workbench on Motia Cloud
  3. Select the port your local project is running on
  4. Choose the project and environment name
  5. Add any environment variables you need (you can upload from .env file or paste the content to auto-fill)
  6. Click Deploy
  7. Watch the magic happen

Adding static files to the bundle

Sometimes we need to use local files when creating our backend logic. For example, creating templates. Running binary files, etc. To do this, we can add them to steps as static files.

Adding them to Steps as static files, you need to add includeFiles to the step config. The path should be relative to the step file.

import { EventConfig } from 'motia'
 
export const config: EventConfig = {
  name: 'Content Outliner',
  description: 'Creates detailed content outline based on the initial idea',
  type: 'event',
  emits: [{ topic: 'write-content', label: 'Write first content' }],
  virtualEmits: ['virtual-write-content'],
  flows: ['Content'],
  subscribes: ['build-outline'],
  input,
  includeFiles: ['./content-outliner.mustache'], // relative to the step file
}

Adding binary files to the bundle

Binary files are also supported, but the entire bundle size must not exceed 100MB. The binary architecture should be linux_amd64.

Troubleshooting Build Outputs

When adding static files, it's important to check the build output to make sure the files are included.

For example, in this project, there are a few steps that include static files.

When running npx motia build, it will generate the following output in dist folder:

dist/
└── node/steps/content/
    ├── agents
    │   ├── content-outliner.step.zip
    │   ├── content-writer.step.zip
    │   └── ideator.step.zip
    ├── api
    │   ├── generate-content-api.step.zip
    │   └── get-content.step.zip
    ├── motia.steps.json
    └── router-node.zip

If you check the content of content-outliner.step.zip, it should have this

steps/
└── content/
    └── agents/
        ├── content-outliner.mustache
        ├── content-outliner.step.js
        └── content-outliner.step.js.map

Now you made sure the static file called content-outliner.mustache is included in the bundle.

Need help? See our Community Resources for questions, examples, and discussions.

On this page