
The database is already in a MongoDB vanilla container that has all the data for this application. As MongoDB is the database engine for our stack, their recommended solution to migrate to serverless is to use MongoDB Atlas. Atlas provides a database cluster in the cloud that scales automatically and you pay for what you use.
To get started, we will create a new Atlas cluster and then migrate the data from the existing database to the serverless one. To migrate the data, you can first dump all the content of the database to a dump folder and then restore it to the cloud:
mongodump --uri="mongodb://<localuser>:<localpassword>@localhost:27017"
mongorestore --uri="mongodb+srv://<user>:<password>@<clustername>.debkm.mongodb.net" .
Your data is now in the cloud. The next step is to change the configuration string in the server to point to the new database.