0% found this document useful (0 votes)
23 views

DevOps Core

Uploaded by

dvpsmaster
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

DevOps Core

Uploaded by

dvpsmaster
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 59

DevOps Core:

1. Fundamentals
2. GIT
3. GITHUB
4. Linux
5. Docker
6. Kubernetes

Fundamentals of IT & DevOps:

1. What is Application
2. What is a Stack
3. What is SDLC, ALM
4. What is Agile
5. What is Scrum
6. VS Code -Code Editor
7. Setup An Application on your Local System

What is Application ?

Software Program for Specific Task

1. Desktop Application
2. Web Appliaction
3. Mobile Appliaction
4. IOT Application
LMS Application:

1. Web Application for Learners


2. Admin App for Admins
3. Mobile APP - Android
4. Mobile APP - IOS

LMS Application Stack:

Programming Languages & Frameworks

HTML, CSS, JS
React JS,Express JS - Node JS
PostGres DB

Software Development Life Cycle (Application Lifecycle Management)


Analysis:

LMS Application:

1. Web Application for Learners


2. Admin App for Admins
3. Mobile APP - Android
4. Mobile APP - IOS

List of features: KonaLMS (initiative)

1. WebApplication

1.1. HomePage
1.2. SignIn
1.3. Landing Page
1.4. Course Page
1.5. ChatBot
1.6. Resources
1.7. Interviews
1.8. Resumes
1.9. Assignments
1.10. Profile Page

Design:

UX Designer : Figma, Adobe XD


Enterpise Architect:

Programming Languages & Frameworks:

HTML, CSS, JS

React JS,Express JS - Node JS


PostGres DB
Version/Source Control: GIT & GITHUB

Code Quality: Sonarcube

Cloud: AWS- EKS Or Azure - AKS

Operating System: Linux

Containerizaion: Docker

Orchestration : Kubernetes, AKS OR EKS

CI/CD: Azure Devops, Jenkins , AWS DevOps

Configuration Management (IAAC): Terraform , Ansible

Moniotoring: Azure Monitoring , AWS Cloud Watch , Prometheus & Graphana

8 AM
7 PM
Development:

Dev Develops code in Local System:

VSCode:

https://code.visualstudio.com

Git: https://git-scm.com/download/win

GITHUB: https://github.com

LMS Applicaiton Code:

https://github.com/KonaMarsTech/lms-public

Testing:

Software testing is the process of evaluating and verifying that a software


product or application does what it is supposed to do. The benefits of testing
include preventing bugs, reducing development costs and improving
performance.

Deployment:

A deployment in general refers to the process of releasing and updating


software applications, services, and infrastructure in a controlled and
predictable manner. It involves creating, testing, and delivering software
updates to various environments such as development, staging, and
production. The goal of a deployment is to ensure that new changes are made
available to end-users in a reliable and consistent manner

https://digital-lync.konalms.com/ - 50,000

https://digital-lync.dev.konalms.com/ 5 De

https://digital-lync.qakonalms.com/ Qa -5

Maintenance:

Maintenance in the Software Development Life Cycle (SDLC) refers to the


ongoing process of updating, improving, and managing software after it has
been developed and deployed.
The maintenance phase of the SDLC includes various tasks such as bug fixing,
security patching, feature enhancements, and performance optimization.
SDLC Methodologies:

Agile Methodology: (Value)


Iteration 1 Iteration 2 Iteration 3

LMS Application:

List of features: KonaLMS (initiative)

1. Web Application Learnners

❖ HomePage
❖ SignIn
❖ Landing Page
❖ Course Page
❖ ChatBot
❖ Resources
❖ Interviews
❖ Resumes
❖ Assignments
❖ Profile Page

2. Admin App for Admins


3. Mobile APP - Android
4. Mobile APP - IOS

Iteration 1:

HomePage
SignIn
Landing Page

Iteration : 2

Course Page
Resources
Interviews
Resumes
Assignments
SCRUM Framework:
Scrum:

Product Backlog:

List of features: KonaLMS (initiative)

5. Web Application Learnners

❖ HomePage
❖ SignIn
❖ Landing Page
❖ Course Page
❖ ChatBot
❖ Resources
❖ Interviews
❖ Resumes
❖ Assignments
❖ Profile Page

6. Admin App for Admins


7. Mobile APP - Android
8. Mobile APP - IOS

Sprint backLog:

Sprint: 1

❖ HomePage
❖ SignIn

Sprint: 2

❖ Landing Page
❖ ChatBot

Sprint: 3

❖ Course Page
❖ ChatBot
❖ Resources

Sprint: 4
❖ Interviews
❖ Resumes
❖ Assignments
❖ Profile Page

Scrum Team: 11

1. Product Owner
2. Business Analyst
3. Scrum Master
4. Designer -1
5. Frontend Dev
6. Backend Developer
7. Full Stack Dev
8. Tester (QA)
9. Cloud DevOps Engineers -2
Epics – Large chunks of work that can be divided into stories
Setup Azure DevOps Account:

First SetUP GITHUB Account:

1. Github.com
2. Dev.azure.com ( Azure DevOps Account)

Epic 1: Core DevOps

1. Fundamentals
2. Git & GitHub
3. Linux
4. LMS Application
5. Docker
6. Kubernetes
7. SonarQube
8. Nexus Repository

DC-Topic-01: Fundamentals of Application Lifecycle Management

- Application
- ALM ( SDLC)
- Agile
- Scrum
- Azure Boards

DC-US-01: Setup Platforms Required for ALM

- Install VSCode
- Install GIT
- Setup GITHUB
- Setup Azure DevOps
- Setup AWS Account
- Setup Azure Account
- Setup GCP Account

DC-IQ-01: Interview for Fundamentals

DC-Topic-02: GIT & GitHub

- Installing GIT
- Git Setup on local
- Git Setup on Linux
- Git Branches
- Git Operations
- SetUp GITHUB
- GITHUB Operations

DC-US-02: Setup LMS GIT in Local and Collarbrate with GitHub

- Clone LMS Code in local


- Make Changes to LMS Code and Test

DC-Topic-03: Linux for DevOps

- What is Linux
- Linux Architecture
- Linux File System
- Linux Commands
- Linux Package Managemnt
- Linux Operations
DC-US-03: Setup Linux VM on Azure, AWS, GCP

DC-Topic-04: LMS Applicaiton on Linux VM

- What is Sever
- What is WebServer
- What is Nginx
- Nginx on Linux
- Three Tier Applicaiton (LMS Applicaiton)

DC-US-04 : Setup LMS Application on Linux VM

DC-Topic-05: Containerization with Docker

- Monolith Vs Microservices
- Evolution of Docker
- What is Docker
- Why Docker
- Docker Architecture
- Docker Image
- Docker Containers
- Dokcer File
- Docker Network
- Docker Volumes
- What is YAML
- Docker Compose

DC-US-05: Setup LMS Application with Docker & Docker Compose

DC-Topic-06: Orchestration with Kubernetes

- What is Kubernetes
- Why Kubernetes
- Kubernetes Architecture
- Kubernetes Objects
- YAML For Kubernetes
- Labels & Selectors
- Namespaces
- Networking

DC-US-06: Setup LMS Application with Kubernetes

DC-Topic-07: Sonorqube

- SonarQube Introduction
- Software Quality
- Static Code Analysis
- Technical Debt
- Static and Dynamic Code Reviews

DC-US-07: SonarQube - Setup

- Setup Sonarcube
- Do Quick Code Analysis

DC-Topic-08: Nexus Repository

- Sonatype Nexus Introduction


- Artifacts Management

US 1: Nexus Setup

- Install Nexus Repository Manager


- Create Nexus Repository

US 2: Nexus Integrations

- Store Java Project Artifacts in Nexus


- Store Docker Images in Nexus
- Nexus Integration with Jenkins
Capstone Project: LMS V2

Version Control:

Version Control, also known as revision control or source control,

Version control is a system that helps to keep track of changes made to a set of files or
code over time. It allows multiple people to work on the same set of files without
overwriting each other's changes.

version control is like a time machine that keeps a record of every change made to a file
or set of files. This means that you can easily go back in time to a previous version of a
file, compare different versions, and see who made what changes and when. It is
commonly used by software developers, but it can also be used for any type of
document or file that undergoes multiple revisions.
● Version control allows for the ability to revert a document to a previous
version.
Centralized Version Control System
Distributed Version Control System
WHAT IS GIT

Git is a free and open-source version control system that helps developers to manage
and track changes in their code over time

Git is like a tool that allows developers to keep track of the changes they make to their
code over time. It keeps a record of every change made to a file, allowing developers to
easily undo changes or go back to an earlier version of their code. Git also allows
multiple developers to work on the same project at the same time without interfering
with each other's work.
What is GITHUB ?

GitHub is a web-based platform that allows developers to store and share their code
with others. It is built on top of Git

It provides a central place to store and manage code repositories, and offers tools for
version control, bug tracking, code review

Repository is like a folder or directory that contains all the files and code related to a
project, along with a record of every change made to those file
Task 1:

Setup GITHUB Account:

Github.com

Create a New repository:

Import LMS CODE:

https://github.com/KonaMarsTech/lms-public.git

Task 2:

Download & Install GIT

https://git-scm.com/

VS Code:

https://code.visualstudio.com/

git clone https://github.com/KonaMarsTech/lms-public.git


SSH keys are a pair of cryptographic keys used to authenticate and secure remote
connections to a server or computer. The pair consists of a public key and a private
key, which are mathematically related but cannot be derived from each other.

When a user attempts to connect to a remote server using SSH, the server sends a
challenge to the user. The user then signs the challenge with their private key and
sends the signed response back to the server. The server then verifies the signature
using the user's public key, which it already has on file. If the signature is valid, the
server grants the user access.

SSH keys are considered more secure than passwords because they are nearly
impossible to guess or crack. They are commonly used by system administrators,
developers, and other IT professionals to securely access remote servers and manage
them.

cd
Ssh-keygen
GIT WORKFLOW:
GIT Commands:
● The git add command - adds a change in the working directory to the
staging area. It tells Git that you want to include updates to a particular
file in the next commit.

● The git commit command - creates a commit, which is like a snapshot of


your repository. These commits are snapshots of your entire repository at
specific times. You should make new commits often, based around logical
units of change. Over time, commits should tell a story of the history of
your repository and how it came to be the way that it currently is.
Commits include lots of metadata in addition to the contents and
message, like the author, timestamp, and more.
○ git commit -m "descriptive commit message"

● The git push command - The git push command is used to upload local
repository content to a remote repository. Pushing is how you transfer
commits from your local repository to a remote repo.

git config --global user.name "kona"

git config --global user.email "[email protected]"

git Status

git --version

git add

git commit -m “Message”

git status

git pull
git push

BRANCHES

Git Branching

● In a collaborative environment, it is common for several developers to


share and work on the same source code.

● Some developers will be fixing bugs while others would be implementing


new features. Therefore, there has got to be a manageable way to
maintain different versions of the same code base.

● This is where the branch function comes to the rescue. Branch allows
each developer to branch out from the original code base and isolate
their work from others. Another good thing about branch is that it helps
Git to easily merge the versions later on.

● It is a common practice to create a new branch for each task


○ (eg. bug fixing, new features etc.)

● Branching means you diverge from the main line(master - working copy of
application) of development and continue to do work without messing
with that main line.
Got to WebApp Folder:

npm install

npm install is a command used in Node.js to install code libraries (also known as
packages or dependencies) that your project needs to run properly. When you run npm
install, it looks at a file called package.json in your project folder and installs all the
libraries listed there. This command is important because it saves you time and effort in
manually installing each library one by one, and ensures that you have all the necessary
components for your project to function.

npm run build

npm run build is a command used in Node.js to prepare your web application for
deployment on a production server. When you run this command, it creates a smaller
and optimized version of your application that is ready to be uploaded to a web server or
hosting service. This optimized version ensures that your application will load faster
and perform better for your users.

Git is maintained by Linux.

Github is maintained by Microsoft.

Git is a command-line tool.

Github is a graphical user Interface.

Git is a Software

Github is a Service

Git was released in 2005.

Github was launched in 2008.


Git is Installed locally on the system.

Github is hosted on the web.

Git has no user management feature.

Github has built-in user management feature.

Git can manage source code history.

Github is a hosting service for git repositories.

Git is focused on version control & code sharing

Github is focused on centralized source code hosting

How to Setup Azure Portal

https://portal.azure.com/

ssh-keygen

Pravite & Public Key:

Home Dir

cd .ssh/
ls

Cat view the content


What is Server:

A server is a computer or system that provides resources or services to other computers or

systems over a network. Servers are typically more powerful and have more storage capacity

than regular desktop computers, as they need to handle multiple requests simultaneously. They

are also designed to run continuously without interruption.


Linux Basics

Introduction to Linux OS

● Today, Linux runs many of the technologies that power up devices and
services. From mobile phones, Google applications, social media
networks, to GPS services, Internet of Things (IoT) and Artificial
Intelligence (AI) products etc.

● All of the fastest 500 supercomputers in the world run on Linux.

● 96.3 percent of the top 1 million web servers run on Linux OS.

● Since DevOps teams share many responsibilities, A DevOps engineer who


knows how to configure/work with linux operating systems and
networking technologies, will potentially have few software delivery
obstacles.

● Knowing how to work with Linux OS is essential for DevOps to a


continual and speedy software delivery process.

Linux Architecture:
Kernel & Shell

● Kernel: Central module(Heart) of OS, interacts with Hardware and


responsible for memory management, process management etc.

● Shell : Shell is a command line interpreter i.e, translates commands


entered by the user and converts them into a language that is understood
by Kernel. Shell is an interface between user and kernel

Topic 2:
Linux File System

The Linux directory structure is like a tree. The base of the Linux file system
hierarchy begins at the root (/). Directories branch off the root, but everything
starts at root.

The directory separator in Linux is the forward slash (/). When talking about
directories and directory paths, “forward slash” is abbreviated to “slash.” Often
the root of the file system is referred to as “slash” since the full path to it is /.

If you hear someone say “look in slash” or “that file is in slash,” they are referring
to the root directory.
File System Structure

● bin - The /bin directory is where you will find binary or executable files.
Programs needed to perform basic tasks, i.e. copy, move, remove etc
● etc - Configuration files live in the /etc directory. Configuration files control
how the operating system or applications behave.
● dev – The /dev directory contains device files that represent hardware
devices of the server
● home - The /home directories allow each user to separate their data from
the other users on the system, contains private directories of users
● mnt - Mount point for external drives connected to this computer, i.e. CDs
or USB keys
● tmp - temporary files, clear the contents of /tmp at boot time. The /tmp
directory is a great place to store temporary files
● var - variable data produced by programs, like logs are stored
● opt - The /opt directory houses optional or third party software.
Navigation In CLI

In windows based machines it’s quite easy to navigate as we have Explorer.


Let’s check how you can move around the linux system using CLI.

> ls /

pwd -

So where are we now ? I mean which directory we are working in now ?


We are going to check pwd which stands for Print Working Directory.
pwd tells you what your current or present working directory is

> pwd

When you first log on to a Linux system, the working directory is set to your
home directory. This is where you put your files. On most systems, your home
directory will be called /home/your_user_name i.e in our case /home/centos.

cd -

The most basic command of all time, cd (change directory). In order to move
around in the system we use the cd command. Typing cd alone without any
argument will bring you to the home directory of the user.
> cd

● ~ (tilde) means the user’s home directory, usually /home/username


● . (dot) means the current directory you’re in
● .. (dot dot) means the parent directory of the current directory you’re in.

> cd ~
> cd /var/log

ls -

It's one thing to know where we are. Next we want to know what’s in there ?
The command for this task is ls. It's short for list. List the contents of a directory.
> ls
> ls /etc

Flags

In addition to performing a general task, a command may also contain flags to


specify a specific task you want the command to do. A flag is anything prefixed
with a dash (-) that follows the command name.

For example, you can type ls -l. In this case, l being the flag, to display the
content of the directory in a list view.

Flags can also be combined. ls -a display all content, including hidden files
(files that are prefixed with a dot). When used with ls -l, we can combine
them like this ls -la
vi Text Editor

The vi editor is the most popular and classic command line text editor in the
Linux family. Below, are some reasons which make it a widely used editor:

● It’s pre installed in almost all Linux Distributions i.e centos, ubuntu etc
● It’s portable i.e it works the same across different platforms
● It is user-friendly, used by millions of linux users

Insert Mode

This mode is for inserting text in the file. You can switch to the Insert mode from
the command mode by pressing 'i' on the keyboard

Once you are in Insert mode, any key would be taken as an input for the file on
which you are currently working. To return to the command mode and save the
changes you must press the esc key

To launch the vim editor


> vi <new-file> or <existing-file>

Create a new file named web.conf generwally .conf indicates configuration files
> vi web.conf

To edit the file we need to switch to insert mode by pressing 'i' on the keyboard
You can tell when you are in insert mode by looking at the bottom left corner.
Now type in a few lines of text and press esc which will take you back to edit
mode. Command beginning with a colon ( : ) requires you to hit <enter> to
complete t:q!

sudo

The sudo command stands for “super user do!”

If you prefix “sudo” with any linux command, it will run that command with
elevated privileges. Elevated privileges are required to perform certain
administrative tasks.

> sudo command

File Management:

COPY

● File
○ cp <source-file> <dest-path>
● Directory
○ cp -r <source-dir> <dest-path>

REMOVE

● File
○ rm <source-file>
● Directory
○ rm -r <source-dir>

RENAME / MOVE

● Rename
○ mv <old-file> <new-file-name>

● Move
○ mv <old-file> <dest-directory>

Package Manager:

In Ubuntu, the default package manager is called "apt" (short for "Advanced Package
Tool"). It is a command-line tool used to manage packages on Ubuntu and other
Debian-based Linux distributions.

To use apt, open a terminal window and enter commands using the following syntax:

To update the package list:

sudo apt update

sudo apt install package-name


The LMS Applicaiton Stack:

Three-Tier Architecture

● Three-tier architecture is a well-established software application


architecture that organizes applications into three logical tiers:
○ the frontend tier, or user interface;
○ the application tier, where data is processed;
○ the data tier, where the data associated with the application is
stored and managed.

● For decades three-tier architecture was the prevailing architecture for


client-server applications.
Presentation Tier / Client-Side Programming

● The frontend tier is the user interface and communication layer of the
application, where the end user interacts with the application.

● Its main purpose is to display information to and collect information


from the user. This top-level tier can run on a web browser, as a desktop
application, or a graphical user interface (GUI), for example.

● Web presentation/Frontend tiers are usually developed using Hypertext


Markup Language (HTML) and Cascading Style Sheets (CSS) and
JavaScript.

● HTML tells a browser how to display the content of web pages, while
CSS styles that content.

● JavaScript (JS). JS makes web pages interactive.

Backend:

the backend refers to the part of a software system or a website that handles the
server-side functionalities, database management, and logic processing that are hidden
from the user interface or front-end.

The backend is responsible for storing and retrieving data from the database,
processing user requests, and generating responses that are sent back to the front-end
for display.
Without the backend, the front-end would not be able to function properly as it would
not have the necessary data and logic to operate. In other words, the backend is the
backbone of any software application or website, providing the necessary support and
functionality for the front-end to work seamlessly.

Database:

a database is an organized collection of data that is stored and managed in a structured


way to allow for efficient retrieval and manipulation of information.

A database typically consists of tables, which contain rows of data that are organized
into columns. Each column represents a different type of information, while each row
contains a specific set of data related to that information. For example, a table for
customer information might have columns for name, address, phone number, and email
address, with each row representing a different customer.

Databases are essential for managing and storing data in a way that allows for easy
retrieval and analysis. They are used in a variety of applications, including web and
mobile applications

An Overview of Nginx

NGINX is open-source software for web serving, reverse proxying, caching, load balancing, media
streaming, and more. It started out as a web server designed for maximum performance and
stability

What is an IP Address?

An IP address (Internet Protocol address) is a numerical label assigned to every device connected
to a computer network that uses the Internet Protocol for communication. It serves two main
functions: identifying the host or network interface and providing the location of the host in the
network.

Versions of IP Address:
IP addresses come in two versions: IPv4 (32-bit) and IPv6 (128-bit). They are usually written as a
series of four numbers separated by dots for IPv4 (e.g. 192.168.1.1) and as eight groups of four
hexadecimal digits separated by colons for IPv6 (e.g.
2001:0db8:85a3:0000:0000:8a2e:0370:7334).

What are port numbers in linux

In Linux, port numbers are 16-bit unsigned integers (0 to 65535) that are used to identify
a specific process to which the data is to be sent once it reaches the host machine. Port
numbers are assigned to well-known services such as HTTP (port 80), HTTPS (port
443), FTP (port 21),SSH Port (22) and others, as well as to custom applications running
on a server. Network services running on a system listen to specific port numbers to
receive incoming data and handle client requests.

why we use port numbers

Port numbers are used in computer networking to identify different applications or


services running on a single host machine. The purpose of using port numbers is to
allow multiple services or applications to run simultaneously on a single machine and to
be reachable by external devices.

When a client wants to communicate with a service on a server, it sends data to the
server's IP address and a specific port number. The operating system of the server then
directs the incoming data to the appropriate service or application based on the port
number. This way, multiple services or applications can share the same IP address but
still be differentiated from each other based on the port number.

Therefore, port numbers allow multiple applications or services to coexist on the same
machine, to be reachable from the network, and to be differentiated from each other for
proper data routing and communication.
What is a Web Server?

A web server is a software application that runs on a computer and provides a platform for serving
web content over the internet. It receives HTTP requests from clients (e.g., web browsers) and
returns the corresponding HTML pages and other assets. Examples of popular web servers include
Apache and Nginx.

Module-4
Why use Web Servers?

Web servers are used for several reasons, including:

1. Serving web content: Web servers are the primary means for serving HTML pages, images,
videos, and other assets over the internet.
2. Routing requests: Web servers can act as a reverse proxy, routing incoming requests to the
appropriate backend servers based on the request URL.
3. Load balancing: Web servers can distribute incoming requests across multiple servers for
better performance and reliability.
4. Security: Web servers can be configured to provide security features such as SSL
encryption, IP blocking, and more.
5. Scalability: Web servers can be easily scaled to handle increasing traffic, making them
suitable for high-traffic websites.
6. Accessibility: Web servers make it possible for people to access content and services from
anywhere with an internet connection.
Module-6
Overview of Nginx

● NGINX is pronounced as "engine-ex".


● It is an open-source, fast, lightweight, and high-performance web server that can be used
to serve static files.
Why use Nginx?
Nginx is used for several reasons, including
● Performance: Nginx is known for its high performance and can handle a large number of
concurrent connections efficiently.
● Scalability: Nginx can easily scale to handle increasing traffic, making it a good choice for
high-traffic websites.
● Reverse proxy: Nginx can act as a reverse proxy, allowing it to route traffic from the
internet to one or more backend servers.
● Load balancing: Nginx can distribute incoming requests to multiple backend servers for
better resource utilization and increased reliability
● Security: Nginx can be configured to provide additional security features, such as SSL
encryption and IP blocking.
● Flexibility: Nginx is highly configurable and can be used for a variety of tasks, such as
serving static files, proxying requests, and more.

Install Nginx on Linux


Here are the steps to install Nginx on an Ubuntu machine:
Nginx file structure on Ubuntu
On an Ubuntu system, the Nginx file structure is typically organized as follows:

Configuration File:
● /etc/nginx/ - Main Nginx configuration directory.
● /etc/nginx/nginx.conf - Main Nginx configuration file.
● /etc/nginx/sites-available/ - Directory for virtual host configurations.
● /etc/nginx/sites-enabled/ - Symbolic links to the virtual host configurations in
sites-available.
● /etc/nginx/snippets/ - Directory for reusable configuration snippets.

Log Files:
/var/log/nginx/ - Directory for Nginx log files.
/var/log/nginx/access.log - Records all HTTP access requests.
/var/log/nginx/error.log - Records all Nginx error messages.

Web root directory:


/var/www/html/ - The default location for web content served by Nginx.

Here are some common Nginx commands on an Ubuntu system:


1. Start Nginx: sudo systemctl start nginx
2. Stop Nginx: sudo systemctl stop nginx
3. Restart Nginx: sudo systemctl restart nginx
4. Start Nginx: sudo systemctl start nginx
5. Nginx Reload: sudo nginx -s reload
6. Check Nginx Status: sudo systemctl status nginx
7. View Nginx Logs: sudo tail -f /var/log/nginx/error.log
8. Test Nginx: sudo nginx -t

Default Configuration Files:


/etc/nginx
Logfiles:
/var/log/nginx
Content:
/var/www/html
azureuser@VMLinuxServer1:/var/www/html$ cp -r /home/azureuser/lms-public/webapp/dist/* .

Nginx Config file for LMS:

server {
server_name konastack.com;
location / {
root /home/azureuser/lms-public/webapp/dist;
}
location /api {
proxy_pass http://localhost:8080;
}
}

This is a Nginx virtual host configuration block that defines a server named
"konastack.com". The block contains two location blocks, which specify how Nginx
should handle incoming HTTP requests based on the URL path.

1. The first location block with a root directory of


/home/azureuser/lms-public/webapp/dist specifies that any requests to the root URL
(e.g. konastack.com/) should be served from the specified directory. Nginx will
look for files in this directory to serve in response to these requests.
2. The second location block with a proxy_pass directive specifies that any requests
to the /api URL (e.g. konastack.com/api) should be proxied to http://localhost:8080.
This means that Nginx will forward these requests to the specified URL and
return the response to the client. This is useful when you want to route requests
to another server or application running on the same host.

This configuration block tells Nginx to listen for requests to the server named
konastack.com and handle them as described above. This configuration block must be
included in the main Nginx configuration file (usually /etc/nginx/nginx.conf) or in a
separate file in the /etc/nginx/sites-available/ directory that is then linked to the
/etc/nginx/sites-enabled/ directory.

1. Setup Azure VM
2. Connect to VM From VS Code

3. install Nginx

sudo apt install nginx

nginx -v

Verify Nginx : sudo systemctl status nginx

Check with IP: IP From Azure

4. Install Node JS Version 16.X

curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - &amp;&amp;sudo apt-get


install -y nodejs

Verify Node is Installed : node -v

5. Install PostGres DB

https://www.postgresql.org/download/linux/ubuntu/

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" >


/etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql

6. setup DB Password : Password can be any thing -password

sudo su postgres

psql

command : \password
postgres=# \password
Enter new password for user "postgres":
Enter it again:
Exit : postgres=# exit

postgres@LMSVMServer:/home/azureuser$ exit

7. Setup LMS Code :

git clone https://github.com/KonaMarsTech/lms-public.git


Get Branches : git branch -r

Change the Branch to vm-docker-cicd

8. Get Nginx ready to Accept the Request for LMS Application

Stop Nginx : sudo systemctl stop nginx

Remove Defualt Config File :

sudo rm /etc/nginx/sites-enabled/default

sudo vi /etc/nginx/sites-available/lms-app

server {
server_name konalms.in;
location / {
root /home/azureuser/lms-public/webapp/dist;
}
location /api {
proxy_pass http://localhost:8080;
}
}

9. Godaddy and Point Domain Name to our Nginx

10. Setup FE and FE


Got to WebApp Folder:

npm install

npm install is a command used in Node.js to install code libraries (also known as
packages or dependencies) that your project needs to run properly. When you run npm
install, it looks at a file called package.json in your project folder and installs all the
libraries listed there. This command is important because it saves you time and effort in
manually installing each library one by one, and ensures that you have all the necessary
components for your project to function.

npm run build

npm run build is a command used in Node.js to prepare your web application for
deployment on a production server. When you run this command, it creates a smaller
and optimized version of your application that is ready to be uploaded to a web server or
hosting service. This optimized version ensures that your application will load faster
and perform better for your users.

11. Create a simlink for Sites Avaiable to Sites Enabled

sudo ln -s /etc/nginx/sites-available/lms-app /etc/nginx/sites-enabled/lms-app

12 Restart Nginx to Access the Front

and Make URL is Up and Running

http://yourdomain

13 Install Certificate to Enable HTTPS

URl : https://certbot.eff.org/instructions?ws=nginx&os=ubuntufocal

Select Ubuntu 20 and Nginx

sudo snap install core; sudo snap refresh core


sudo snap install --classic certbot

sudo ln -s /snap/bin/certbot /usr/bin/certbot

sudo certbot --nginx

Give Email ID :
Say : Y,Y
Select : 1

14: Set Backend API

Go to API Folder

npm install

Install PM2 : Node Process Manager

sudo npm install -g pm2

Give DB info in Env File :

sudo vi .env

Go to Insert Mode by typing i

Paste the below code

MODE=production
PORT=8080
DATABASE_URL=postgresql://postgres:password@localhost:5432/postgres

Exit with :wq

15: Get DataBase Ready

npx prisma db push


16 Build and Run Backend:

npm run build

NODE_PORT=8080 pm2 start -i 0 build/index.js

You might also like