117 lines
3.2 KiB
TeX
117 lines
3.2 KiB
TeX
\chapter{Digital Ocean Docker Deployment}
|
|
\ChapterLabel{DigitalOceanDockerDeployment}
|
|
\index{Digital Ocean}
|
|
\index{Docker}
|
|
|
|
\section{Overview}
|
|
|
|
For this assignment, our group used a Digital Ocean Droplet to provide
|
|
a remote Linux environment for deploying Docker containers. The Droplet
|
|
was configured with Ubuntu 24.04 LTS. Docker was then used to deploy the
|
|
web applications developed for the assignment.
|
|
|
|
\section{Digital Ocean Droplet}
|
|
|
|
A Digital Ocean Droplet was created using Ubuntu 24.04 LTS. After the
|
|
Droplet became active, its public IPv4 address was used to connect to
|
|
the remote server.
|
|
|
|
\begin{center}
|
|
\includegraphics[width=0.75\linewidth]{digital.png}
|
|
\end{center}
|
|
|
|
The Droplet was accessed remotely using SSH:
|
|
|
|
\begin{minted}[breaklines,fontsize=\small]{bash}
|
|
ssh root@147.182.167.190
|
|
\end{minted}
|
|
|
|
\section{Docker Setup}
|
|
|
|
After connecting to the Droplet, Docker was installed and verified on
|
|
the remote server. The Docker installation was checked using commands
|
|
such as:
|
|
|
|
\begin{minted}[breaklines,fontsize=\small]{bash}
|
|
docker --version
|
|
docker images
|
|
docker ps -a
|
|
\end{minted}
|
|
|
|
\section{Web Application Deployment}
|
|
|
|
The web applications were packaged as Docker images and deployed as
|
|
containers on the Digital Ocean Droplet.
|
|
|
|
The Hello World application uses container port 3000 and maps it to
|
|
port 5050 on the host:
|
|
|
|
\begin{minted}[breaklines,fontsize=\small]{bash}
|
|
docker build -t hello-node .
|
|
docker run -p 5050:3000 hello-node
|
|
\end{minted}
|
|
|
|
The Color Buttons application uses container port 3000 and maps it to
|
|
port 8080 on the host:
|
|
|
|
\begin{minted}[breaklines,fontsize=\small]{bash}
|
|
docker build -t color-buttons-app .
|
|
docker run -p 8080:3000 color-buttons-app
|
|
\end{minted}
|
|
|
|
\section{Deployed Websites}
|
|
|
|
The applications are accessed through the public IP address of the
|
|
Digital Ocean Droplet.
|
|
|
|
\begin{itemize}
|
|
\item Hello World Website:
|
|
\url{http://147.182.167.190:5050}
|
|
|
|
\item Color Buttons Website:
|
|
\url{http://147.182.167.190:8080}
|
|
\end{itemize}
|
|
|
|
\section{Class-Based JavaScript Design}
|
|
|
|
The Two Buttons website was updated to use a class-based JavaScript
|
|
design. The \texttt{ColorButtons} class manages the two button elements
|
|
and changes the background color of the webpage when a button is
|
|
selected.
|
|
|
|
\begin{minted}[breaklines,fontsize=\small]{javascript}
|
|
class ColorButtons {
|
|
constructor() {
|
|
this.blueButton = document.getElementById("blueBtn");
|
|
this.redButton = document.getElementById("redBtn");
|
|
|
|
this.blueButton.addEventListener("click", () => {
|
|
this.changeBackground("blue");
|
|
});
|
|
|
|
this.redButton.addEventListener("click", () => {
|
|
this.changeBackground("red");
|
|
});
|
|
}
|
|
|
|
changeBackground(color) {
|
|
document.body.style.backgroundColor = color;
|
|
}
|
|
}
|
|
|
|
new ColorButtons();
|
|
\end{minted}
|
|
|
|
\subsection{UML Class Diagram}
|
|
|
|
The UML class diagram below represents the updated class-based design.
|
|
The \texttt{ColorButtons} class contains references to the Blue and Red
|
|
buttons and provides the \texttt{changeBackground(color)} operation.
|
|
|
|
\begin{center}
|
|
\includegraphics[width=0.55\linewidth]{coloruml.png}
|
|
\end{center}
|
|
|
|
The deployment demonstrates how the applications can be packaged into
|
|
Docker containers and executed on a remote Linux server instead of only
|
|
on the local development machine. |