Manual deployment of NestJS and Angular applications on a dedicated server via "Docker Compose" and "PM2"
Publication date: 2024-08-22
We buy a dedicated server and configure SSH access to it from a local computer.
Adding https://github.com/SteveLTN/https-portal in "Docker compose" for automatic generation and renewal of certificates.
1. Find a free or buy a dedicated server
I will not describe the steps on this point, I have already described them earlier in the "Buy VPS" section of another post - Deploy nestjs project to VPS with dokku.
As part of the current posts, I bought the cheapest dedicated server on the same site.
Operating system: Ubuntu 22.04 x64
Access to the world: 100 MB/sec (shared)
RAM: 2GB
CPU: 2 vCPUs
Number of IPv4 address: 1
When buying a dedicated server, I was also given a third-level domain: vps1724252356.tech0.ru in the future, this project will move to the domain https://fullstack.nestjs-mod.com .
2. After purchase, you need to set a password if it has not been set, different sites have their own interfaces for this, in my case, setting the password is on the page https://ztv.su/clientarea.php?action=productdetails&id=33376#tabChangepw .
We copy our local public SSH to a remote server, at startup you will be prompted to enter a password, you need to enter your password and press "Enter".
If there was no SSH key on the computer, then you need to create it using the ssh-keygen command
Commands
ssh-copy-id root@194.226.49.162
$ ssh-copy-id root@194.226.49.162
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/user/.ssh/id_rsa.pub"
The authenticity of host '194.226.49.162 (194.226.49.162)' can't be established.
ECDSA key fingerprint is SHA256:SOME_SYMBOLS.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@194.226.49.162's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@194.226.49.162'"
and check to make sure that only the key(s) you wanted were added.
3. Connecting to a remote server
Commands
ssh root@194.226.49.162
$ ssh root@194.226.49.162
Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 5.15.0-91-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Wed Aug 21 18:42:37 MSK 2024
System load: 0.02734375 Processes: 103
Usage of /: 9.4% of 24.05GB Users logged in: 0
Memory usage: 10% IPv4 address for eth0: 194.226.49.162
Swap usage: 0%
* Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
just raised the bar for easy, resilient and secure K8s cluster deployment.
https://ubuntu.com/engage/secure-kubernetes-at-the-edge
Expanded Security Maintenance for Applications is not enabled.
0 updates can be applied immediately.
Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status
The list of available updates is more than a week old.
To check for new updates run: sudo apt update
Last login: Wed Aug 21 18:41:46 2024 from X.X.X.X
root@vps1724252356:~#