# Digital Ocean Deploy your Mastra applications to Digital Ocean's App Platform and Droplets. This guide assumes your Mastra application has been created using the default `npx create-mastra@latest` command. For more information on how to create a new Mastra application, refer to our [getting started guide](https://mastra.ai/guides/getting-started/quickstart/llms.txt) ## Instructions ### Prerequisites - A Git repository containing your Mastra application. This can be a [GitHub](https://github.com/) repository, [GitLab](https://gitlab.com/) repository, or any other compatible source provider. - A [Digital Ocean account](https://www.digitalocean.com/) ### Deployment Steps 1. Create a new App - Log in to your [Digital Ocean dashboard](https://cloud.digitalocean.com/). - Navigate to the [App Platform](https://docs.digitalocean.com/products/app-platform/) service. - Select your source provider and create a new app. 2. Configure Deployment Source - Connect and select your repository. You may also choose a container image or a sample app. - Select the branch you want to deploy from. - Configure the source directory if necessary. If your Mastra application uses the default directory structure, no action is required here. - Head to the next step. 3. Configure Resource Settings and Environment Variables - A Node.js build should be detected automatically. - **Configure Build Command**: You need to add a custom build command for the app platform to build your Mastra project successfully. Set the build command based on your package manager: ```bash npm run build ``` ```bash pnpm run build ``` ```bash yarn build ``` ```bash bun run build ``` - Add any required environment variables for your Mastra application. This includes API keys, database URLs, and other configuration values. - You may choose to configure the size of your resource here. - Other things you may optionally configure include, the region of your resource, the unique app name, and what project the resource belongs to. - Once you're done, you may create the app after reviewing your configuration and pricing estimates. 4. Deployment - Your app will be built and deployed automatically. - Digital Ocean will provide you with a URL to access your deployed application. You can now access your deployed application at the URL provided by Digital Ocean. The Digital Ocean App Platform uses an ephemeral file system, meaning that any files written to the file system are short-lived and may be lost. Remove any usage of [LibSQLStore](https://mastra.ai/reference/storage/libsql/llms.txt) with file URLs from your Mastra configuration. Use in-memory storage (`:memory:`) or external storage providers like Turso, PostgreSQL, or Upstash. Deploy your Mastra application to Digital Ocean's Droplets. ### Prerequisites - A [Digital Ocean account](https://www.digitalocean.com/) - A [Droplet](https://docs.digitalocean.com/products/droplets/) running Ubuntu 24+ - A domain name with an A record pointing to your droplet - A reverse proxy configured (e.g., using [nginx](https://nginx.org/)) - SSL certificate configured (e.g., using [Let's Encrypt](https://letsencrypt.org/)) - Node.js 22.13.0 or later installed on your droplet ### Deployment Steps 1. Clone your Mastra application Connect to your Droplet and clone your repository: ```bash git clone https://github.com//.git ``` ```bash git clone https://:@github.com//.git ``` Navigate to the repository directory: ```bash cd "" ``` 2. Install dependencies ```bash npm install ``` 3. Set up environment variables Create a `.env` file and add your environment variables: ```bash touch .env ``` Edit the `.env` file and add your environment variables: ```bash OPENAI_API_KEY= # Add other required environment variables ``` 4. Build the application ```bash npm run build ``` 5. Run the application ```bash node --env-file=".env" .mastra/output/index.mjs ``` Your Mastra application will run on port 4111 by default. Ensure your reverse proxy is configured to forward requests to this port. ## Connect to your Mastra server You can now connect to your Mastra server from your client application using a `MastraClient` from the `@mastra/client-js` package. Refer to the [`MastraClient` documentation](https://mastra.ai/docs/server/mastra-client/llms.txt) for more information. ```typescript import { MastraClient } from "@mastra/client-js"; const mastraClient = new MastraClient({ baseUrl: "https://", }); ``` ## Next steps - [Mastra Client SDK](https://mastra.ai/reference/client-js/mastra-client/llms.txt) - [Digital Ocean App Platform documentation](https://docs.digitalocean.com/products/app-platform/) - [Digital Ocean Droplets documentation](https://docs.digitalocean.com/products/droplets/)