This guide describes how to set up and deploy a Medusa backend using DigitalOcean App Platform with managed PostgreSQL and Valkey databases.
Prerequisites
Before you begin, make sure you have the following:
- A DigitalOcean account
- Git installed on your local machine
- A GitHub account
1. Create Managed Database Instances
PostgreSQL Configuration
-
In your DigitalOcean dashboard, go to Databases and click Create Database Cluster.
-
Choose PostgreSQL as the database type.
-
Configure your instance with the following options:
- CPU options: Regular
- Plan: 1 vCPU / 1 GB RAM / 10 GB Storage / Connection limit: 22
- Storage size: 10 GB
- Optional: Enable autoscaling if desired
- Region: Choose the same region you plan to deploy your app in
- Expected cost: $15.15 per month
-
Once the database is created, open the Connection Details tab and copy the connection string. It should look like this:
postgres://<user>:<password>@<host>:<port>/<database>?sslmode=require -
Save this connection string. You will need to modify it later to set
sslmode=no-verify.
Valkey Configuration
-
Go to Databases again and click Create Database Cluster.
-
Choose Valkey.
-
Use the $15 per month plan.
-
Copy the connection string, which typically looks like:
redis://<user>:<password>@<host>:<port> -
Save this string for use in your environment variables.
2. Prepare the Medusa Project
-
Fork the official Medusa starter project: https://github.com/medusajs/medusa-starter-default
-
In your forked repository:
- Download and use the Medusa configuration file from: https://github.com/u11d-com/medusa-starter/blob/main/backend/medusa-config.ts
- Download and use the startup script from: https://github.com/u11d-com/medusa-starter/blob/main/backend/start.sh
-
Modify the
package.jsonfile to update the start command only:{ "scripts": { "start": "./start.sh" } } -
Commit and push your changes to GitHub.
3. Deploy on DigitalOcean App Platform
-
In your DigitalOcean dashboard, go to Apps and click Create App.
-
Connect your GitHub account and select the repository you forked.
-
Choose the branch you want to deploy (for example,
main). -
In the deployment settings, provide the following:
- Build Command:
yarn run build - Run Command:
yarn run start - Network: Public
- Port: 9000
- Build Command:
-
Under Environment Variables, add the following variables:
Variable Description DATABASE_URLPostgreSQL connection string, but replace sslmode=requirewithsslmode=no-verifyREDIS_URLValkey connection string CACHE_REDIS_URLSame as Valkey connection string LOCKING_REDIS_URLSame as Valkey connection string EVENTS_REDIS_URLSame as Valkey connection string WE_REDIS_URLSame as Valkey connection string NODE_ENVproductionMEDUSA_CREATE_ADMIN_USERSet to trueto create an admin user on startupMEDUSA_ADMIN_EMAILEmail address for the initial admin user MEDUSA_ADMIN_PASSWORDPassword for the initial admin user -
Make sure to select the same data center region as your PostgreSQL and Valkey databases.
-
Set a health check path to
/health.
4. Build and Verify
-
Click Deploy App.
-
Wait for the build process to complete. This may take several minutes.
-
Once deployed, test your Medusa backend by visiting:
https://<your-app>.ondigitalocean.app/healthYou should receive a healthy response if everything is set up correctly.
-
The Medusa Admin panel will be available at the following path:
https://<your-app>.ondigitalocean.app/app
Summary
You have now deployed a Medusa backend on DigitalOcean App Platform using managed PostgreSQL and Valkey services. Your environment is configured for production with an optional admin user creation process and accessible admin panel at the /app path.