Setting Up a Database for a NextJS App on AWS
This page explains how to set up a database on AWS 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​
In the
Application Menu
, click on+ Create App
.Fill out the form. Here is some information you need to consider:
General
Name
: Provide a name for your database application.Server
: Select your AWS server.Type
: ChoosePostgresSQL
to set up a PostgreSQL Database.
Database
Username
: Set your username for database access.Password
: Assign a password for database access credentials.
Click on
Create Application
button and wait for the status to change to running. To monitor the status change, you can use therefresh button
.
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 theCreate database
button.
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 theAdd Database
button.This is how it appears after you've created a database.
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.
Get started​
In the
Application Menu
, click on+ Create App
.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) serverType
: 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"
Click on
Create Application
button and wait for the status to change to running. To monitor the status change, you can use therefresh button
.
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.
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