How to deploy Amplication app to DigitalOcean

This article shows you the way to deploy an app generated by Amplication to DigitalOcean. Amplication provides the dockerfile to use containers for deployment, but this blog explains how to do it manually. I will guide you step by step to deploy Nestjs app and Postgres database with DOCKER, NGINX and PM2.

1. Sign up a Digital Ocean account

2. Create a droplet

  • Click on “Create” button and select create droplet
  • Config your droplet (CPU, region, ssh,…)
  • Waiting for your machine initialization
  • After finish loading, go to tab “Access”, you will see a button to load the console.

3. Install Nodejs, NPM

sudo apt update
sudo apt install nodejs
sudo apt install npm

4. Install Docker

  • Install HTTPS packages:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
  • Add the GPG key to your system:
curl -fsSL | sudo apt-key add -
  • Add repository to APT sources:
sudo add-apt-repository "deb [arch=amd64] bionic stable"
  • Install Docker:
sudo apt install docker-ce
  • Finally, Install Docker Compose:
sudo curl -L`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

5. Clone project from your git repository

git clone<username>/<repo-name>.git

If you don’t see your code, please checkout this document on how to sync your code from Amplication to GitHub
You can also use my repo for testing:

6. Install dependencies and initialize database

  • Go to server folder and install dependencies
cd <your-repo>/server
npm install
  • Generate Prisma client
npm run prisma:generate
  • Start database in Docker
npm run docker:db
  • Initiate the database
npm run db:init
  • Start the server
npm start

Go to <droplet-ip-address>:3000 (example:, you will see the response from server.

7. Setup PM2 to manage process

  • Install PM2
sudo npm i pm2 -g
  • Create an app
pm2 start dist/main.js --name myserver

Your app is now running!

  • View logs of app
pm2 logs myserver

8. Setup ufw firewall

sudo ufw enable
sudo ufw status
sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https

9. Setup NGINX as a reverse proxy

  • Install nginx
sudo apt install nginx
  • Open config file
sudo nano /etc/nginx/sites-available/default
  • Add the following to location block
 location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
  • Check NGINX config correctly
sudo nginx -t
  • Restart NGINX
sudo service nginx restart

Visit <droplet-ip-address> (example:, you will see app running without port. That’s awesome!

10. Here’s my result


These are the sources that I have consulted:


Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *