Skip to main content

Setting Up a Database for a NextJS App on App Platform (DO)

This page explains how to set up a database on DigitalOcean App Platform for a NextJS App using DeployPRO. Also, it's important to understand that you can create multiple databases within your application using either the PostgreSQL or MySQL types.

Take a look at the sample app here. Feel free to make a copy of it for your reference.

👉 Make sure to include the Dockerfile in your application's GitHub repository.


Set Up Database​

  1. In the Application Menu, click on + Create App.

  2. Fill out the form. Here is some information you need to consider:

    General

    • Name: Provide a name for your database application.
    • Server: Select your App Platform (DO) server.
    • Type: Choose PostgresSQL to set up a PostgreSQL Database.

    Database

    • Username: Set your username for database access.
    • Password: Assign a password for database access credentials.

  1. Click on Create Application button and wait for the status to change to running. To monitor the status change, you can use the refresh button.

    DeployPRO - Application created


  1. Once the application is running, you can begin creating a database within it. Navigate to the App details by clicking the App name and click the Create database button.

    Create Database - DeployPRO


  1. Next, you need to provide a name for the database. For this example, since the database is intended for a Next.js project, you can name it nextjs-project. After that, click the Add Database button.

    Modal Database - DeployPRO


    This is how it appears after you've created a database.

    Database Created - DeployPRO

Deploy Project with a Database​

To deploy the project, you'll follow the same steps as usual. To add a database within the application, simply include a key and its corresponding value in the environment variables. The format for the key and value is as follows:

POSTGRES_PRISMA_URL="postgresql://USER:PASSWORD@HOST:PORT/DATABASE?schema=sample"

Here's how you can fill in the values:

  • USER: Use the username you created for database access.
  • PASSWORD: Use the password you created for database access credentials.
  • HOST: Enter the name of your database application.
  • PORT: Enter the container port of the database you created.
  • DATABASE: Specify the name of the database within your database application.

Database Value - DeployPRO


Get started​

  1. In the Application Menu, click on + Create App.

  2. Fill out the form by providing the Application name and Environment Variable if needed. Here is some information you need to consider:

    General

    • Server : Select your App Platform (DO) server
    • Type: Deploy from source code

    Detail

    • Repo ( Select the repository you are going to deploy )
    • Dockerfile Path ( Right now, DeployPRO still needs your manual input for the location of your dockerfile inside the repository )
    • Container Port ( Please manually input the port form your dockerfile )
    • Domain ( Provide any domain name for your application. We also support Custom Domain!)

    Environment Variable

    • Fill out Key and Value in case you need to add some variable.
    • Add the the following key and it's corresponding value:
    POSTGRES_PRISMA_URL="postgresql://USER:PASSWORD@HOST:PORT/DATABASE?schema=sample"

  1. Click on Create Application button and wait for the status to change to running. To monitor the status change, you can use the refresh button.

    DeployPRO - Application created


  1. Once the application is successfully deployed, you can proceed to visit the domain.

    Since the application includes a database, you can experiment by posting or creating data. Afterward, reload the domain, and the application will retrieve the data stored within the database.

    Domain - DeployPRO


If you encounter some issue while deploying your application, don't hesitate to inform us! 😉


✅ Resources​

  • 👉 Deploy Projects using your preferred provider: AWS, DigitalOcean, Azure, and GCP (soon)
  • 👉 Get Deployment Support from the team behind this service
  • 👉 Join the Community and chat with the team behind DeployPRO