-
Create a VM a. Allow SSH access via key. Add your public key while you create a VM.
-
Install packages:
sudo apt-get update sudo apt install -y nginx sudo apt install -y git curl -sL https://deb.nodesource.com/setup_16.x | sudo bash - sudo apt -y install nodejs sudo apt install -y certbot python3-certbot-nginx -
Clone the repo under home directory:
git clone https://github.com/ajaysourcedigital/test-app.git -
Create
script.shfile under/home/with below content:#!/bin/bash cd /home/ajaykumar/hello-world git checkout main git pull sudo systemctl restart hello.servicehello.serviceis described at step 6.
-
Change the content of
/etc/nginx/sites-enabled/defaultto :location / { proxy_pass http://127.0.0.1:3000; }- Any changes you do to
defaultnginx file, you have to runsudo systemctl restart nginx
- Any changes you do to
-
create systemctl service under
/etc/systemd/system/hello.service:[Unit] Description=API service [Service] User=ajaykumar Restart=always KillSignal=SIGQUIT WorkingDirectory=/home/ajaykumar/hello-world ExecStart=/usr/bin/node app.js [Install] WantedBy=multi-user.targetonce created you have enable the systemctl daemon process:
systemctl enable hello.serviceIf you do any changes to hello.service file, you have to restart daemon:
systemctl daemon reload -
Generate SSL certificate:
sudo certbot --nginx -d ajay.domain.com
8 CICD:
look at .github/workflows/main.yaml