DEV Community

Brian
Brian

Posted on

Deploying Strapi using Digital Ocean's App Platform and Managed DB

In this article, I'm going to share how I deployed one of my apps using Digital Ocean. This should take you around 15-20 minutes.

Updating your code for different environments

Most of the time, I only have 3 environments in my application; development, staging and production.
To create these configurations, you need to create these folders:
config > env > {configName }

Alt Text
Take note of your environment variables, we're going to need them later in App Platform.

You can learn more from the official doc

Setting up Managed DB

Alt Text
Make sure to choose MySQL. For some reasons, I was not able to connect using Postgres.

For other options, just pick according to your needs.

After provisioning is done, create a new user which you are going to use later to connect to your app.

Alt Text
For Password Encryption, use the Legacy – MySQL 5.x. I'm not a DB expert and it took me a lot of time to figure out this one.

Take note of the connection details found here
Alt Text
You will need them later when setting up the environment variables.

DB part is done and now we go to the App Platform

Setting up App Platform

App platform will prompt you to choose your git repo and branch to deploy from.

After clicking Next, you will be prompted similar to this screenshot

Alt Text
The important part here is the Environment Variables. You can set them now or just do it later. For Build/Run Command, you don't need to change it since the scripts in your package.json already had the same names and working accordingly.

Set the values of your Environment variables now if you haven't because the build will fail without them.
You can go to the Components tab > Environment variables

Alt Text
You can freely choose your own variable names and don't need to necessarily copy mine. After clicking save, App Platform will rebuild your app.

If the build finish successfully, you will see a link in your dashboard like this

Alt Text

Feedback is welcome. If you have a better way of doing things, please comment it down below.

If you reached this section, please consider using my affiliate link when creating a new account :D
You will get $100 in credit over 60 days
https://m.do.co/c/5c95573fc1d2

Top comments (0)