docs/src/content/en/guides/deployment/digital-ocean.mdx
import Steps from "@site/src/components/Steps"; import StepItem from "@site/src/components/StepItem"; import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem";
This guide covers Digital Ocean's App Platform and Droplets. Each of these offerings has its own set of strengths and is suited for different types of projects and developer expertise. Read Digital Ocean's comparison to understand the differences and choose the best option for your project.
:::info This guide covers deploying the Mastra server. If you're using a server adapter or web framework, deploy the way you normally would for that framework. :::
You'll need a Mastra application and a Digital Ocean account.
The App Platform uses an ephemeral filesystem, so any storage you configure (including observability storage) must be hosted externally. If you're using LibSQLStore with a file URL, switch to a remotely hosted database.
After setting up your project, push it to your remote Git provider of choice (e.g. GitHub).
<Steps> <StepItem> Follow the official [App Platform quickstart](https://docs.digitalocean.com/products/app-platform/getting-started/quickstart/#create-an-app). It'll guide you through connecting your repository, selecting the branch to deploy from, and configuring the source directory if necessary. </StepItem> <StepItem> Make sure that a "Node.js" build is detected. You'll need to configure a build command. Set it based on your package manager:```bash npm2yarn
npm run build
```
:::warning
Set up [authentication](/docs/server/auth) before exposing your endpoints publicly.
:::
After setting up your project, push it to your remote Git provider of choice (e.g. GitHub). Connect to your Droplet and make sure git is installed.
<Tabs>
<TabItem value="public" label="Public Repository">
```bash
git clone https://github.com/<your-username>/<your-repository>.git
```
</TabItem>
<TabItem value="private" label="Private Repository">
```bash
git clone https://<your-username>:<your-personal-access-token>@github.com/<your-username>/<your-repository>.git
```
</TabItem>
</Tabs>
Navigate to the repository directory:
```bash
cd "<your-repository>"
```
```bash npm2yarn
npm install
```
```bash
touch .env
```
Edit the `.env` file and add your environment variables:
```bash title=".env"
OPENAI_API_KEY=your-api-key
```
```bash npm2yarn
npm run build
```
This will create a production build of Mastra's server in the `.mastra/output` directory.
```bash
mastra start
```
:::info
Your Mastra application will run on port 4111 by default. Ensure your reverse proxy is configured to forward requests to this port.
:::
:::warning
Set up [authentication](/docs/server/auth) before exposing your endpoints publicly.
:::