Effortless Deployment: AdonisJs on DigitalOcean

Getting Started with DigitalOcean

In the world of Node.js, AdonisJs stands out as a framework that prioritizes speed and stability. To take full advantage of its capabilities, we’ll explore how to deploy an AdonisJs application on DigitalOcean, a cloud infrastructure provider offering a flexible and scalable platform.

Prerequisites

Before diving in, make sure you have:

  • Basic knowledge of Node.js (AdonisJs in particular)
  • Familiarity with Git
  • npm or Yarn installed
  • A DigitalOcean account

Creating a Droplet

To begin, log in to your DigitalOcean account and create a server by clicking the “Create” button. Choose an image from the distributions, such as Ubuntu 20.04 (LTS), and select a plan that suits your needs. Remember to choose a datacenter region close to your target audience. Add your SSH Key to the droplet, following the instructions carefully to avoid confusion.

Configuring the Server

Next, add SSH to your server and create a new user with administrative privileges. Log in as root using your server’s IP address, then add the user to the sudo group. Create a directory called .ssh and a file authorized_keys to store your SSH key. Change the permissions accordingly and paste your copied SSH key into the file.

Installing and Setting up MySQL

Our demo application uses MySQL, so we’ll need to install and configure it on our server. Log in to the MySQL server, create a new user and database, and grant all privileges. Don’t forget to flush the changes and exit.

Cloning the Application

Clone your AdonisJs application from Github into your server using Git. Install dependencies, create an .env file, and generate your application key. Paste the key and other variables into the .env file. Run migrations to create tables, and start your application.

Configuring Nginx

To set up reverse proxy, open the Nginx configuration file and edit it to listen to incoming domain requests and forward them to the PORT in your local server network. Replace server_name with your IP address or domain name. Restart Nginx to apply the changes.

Deploying with Ease

With these steps, you’ve successfully deployed your AdonisJs application to DigitalOcean. You can now access your application by hitting the IP of your server. Consider adding an auto-deployment script to streamline your process. Explore the demo application’s source code on Github and feel free to clone it.

Monitoring Performance

To ensure your Node instance continues to serve resources efficiently, try LogRocket. This powerful tool records everything that happens while a user interacts with your app, helping you identify and resolve performance issues quickly. Start monitoring for free today!

Leave a Reply

Your email address will not be published. Required fields are marked *