Build the complete Assignment 5 manual on trusted branch pushes
Assignment 5 manual PDF / manual (push) Successful in 47s
Assignment 5 manual PDF / manual (push) Successful in 47s
This commit is contained in:
parent
fa9a32f8a9
commit
c74087a93b
@@ -0,0 +1,190 @@
|
||||
\chapter{DigitalOcean Docker Deployment}
|
||||
\ChapterLabel{DigitalOceanDockerDeployment}
|
||||
\index{DigitalOcean!Docker deployment}
|
||||
\index{Docker!Ubuntu installation}
|
||||
|
||||
\section{Overview}
|
||||
|
||||
The team created an Ubuntu Droplet in the DigitalOcean project named
|
||||
\textit{SSW 590 DevOps}. The Droplet is currently named
|
||||
\texttt{ssw590-group7-droplet} and has one virtual CPU, 1 GB of RAM, 25 GB of
|
||||
disk space, and the public IP address
|
||||
\href{http://142.93.193.110}{142.93.193.110}. Docker Engine was then installed
|
||||
on the Droplet by following Docker's official Ubuntu installation instructions
|
||||
\cite{DockerUbuntuInstall}. Figure~\ref{fig:digitalocean-droplet} preserves the
|
||||
original pre-upgrade cloud-console view; the text and host registry record the
|
||||
current name and capacity.
|
||||
|
||||
\begin{figure}[htbp]
|
||||
\centering
|
||||
\includegraphics[width=\textwidth]{digitalocean-droplet.png}
|
||||
\caption{Original pre-upgrade view of the Ubuntu Droplet in the SSW 590
|
||||
DevOps project; the current resource is named
|
||||
\texttt{ssw590-group7-droplet} with 1 GB RAM and 25 GB storage.}
|
||||
\label{fig:digitalocean-droplet}
|
||||
\end{figure}
|
||||
|
||||
\FloatBarrier
|
||||
|
||||
\section{Installing Docker Engine on Ubuntu}
|
||||
|
||||
The package index was updated, the required certificate and download utilities
|
||||
were installed, and Docker's official GPG key was saved in the APT keyring.
|
||||
|
||||
\begin{minted}{bash}
|
||||
sudo apt update
|
||||
sudo apt install ca-certificates curl
|
||||
sudo install -m 0755 -d /etc/apt/keyrings
|
||||
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
|
||||
-o /etc/apt/keyrings/docker.asc
|
||||
sudo chmod a+r /etc/apt/keyrings/docker.asc
|
||||
\end{minted}
|
||||
|
||||
The Docker repository was then added to the Ubuntu APT sources. The suite and
|
||||
architecture values were determined automatically from the operating system.
|
||||
|
||||
\begin{minted}{bash}
|
||||
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
|
||||
Types: deb
|
||||
URIs: https://download.docker.com/linux/ubuntu
|
||||
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
|
||||
Components: stable
|
||||
Architectures: $(dpkg --print-architecture)
|
||||
Signed-By: /etc/apt/keyrings/docker.asc
|
||||
EOF
|
||||
|
||||
sudo apt update
|
||||
sudo apt install docker-ce docker-ce-cli containerd.io \
|
||||
docker-buildx-plugin docker-compose-plugin
|
||||
\end{minted}
|
||||
|
||||
After installation, Docker was checked before the application images were
|
||||
built and started.
|
||||
|
||||
\begin{minted}{bash}
|
||||
sudo systemctl status docker
|
||||
sudo docker --version
|
||||
sudo docker run hello-world
|
||||
\end{minted}
|
||||
|
||||
\section{First Container: Hello World Website}
|
||||
|
||||
Following Section 2.5 of the supplied Docker setup guide, the team created a
|
||||
minimal Node.js HTTP server, its \texttt{package.json}, a
|
||||
\texttt{.dockerignore} file, and a Dockerfile based on
|
||||
\texttt{node:20-alpine}. The image was built as \texttt{hello-node}; container
|
||||
port 3000 was published through host port 5050.
|
||||
|
||||
\begin{minted}{bash}
|
||||
cd hello-node-docker
|
||||
sudo docker build -t hello-node .
|
||||
sudo docker run -d --name hello-node -p 5050:3000 hello-node
|
||||
sudo docker ps
|
||||
\end{minted}
|
||||
|
||||
The deployed endpoint is
|
||||
\href{http://142.93.193.110:5050}{http://142.93.193.110:5050}.
|
||||
|
||||
\section{Second Container: Two Buttons Website}
|
||||
|
||||
Following Section 2.6 of the supplied guide, the team created an Express-based
|
||||
Node.js website with Blue and Red buttons. The project contained
|
||||
\texttt{server.js}, \texttt{package.json}, \texttt{public/index.html},
|
||||
\texttt{public/script.js}, and a Dockerfile. For Assignment 3 Step 3, the
|
||||
original direct event-listener functions were replaced by a reusable
|
||||
\texttt{ColorButtonController} class. Each button is represented by an instance
|
||||
that stores its DOM element and target color, binds its click event, and changes
|
||||
the page background through a class method.
|
||||
|
||||
\subsection{Class-Based JavaScript Implementation}
|
||||
|
||||
\begin{minted}{javascript}
|
||||
class ColorButtonController {
|
||||
constructor(buttonId, color) {
|
||||
this.button = document.getElementById(buttonId);
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
changeBackground() {
|
||||
document.body.style.backgroundColor = this.color;
|
||||
}
|
||||
|
||||
bind() {
|
||||
this.button.addEventListener("click", () => this.changeBackground());
|
||||
}
|
||||
}
|
||||
|
||||
const blueButton = new ColorButtonController("blueBtn", "blue");
|
||||
const redButton = new ColorButtonController("redBtn", "red");
|
||||
|
||||
blueButton.bind();
|
||||
redButton.bind();
|
||||
\end{minted}
|
||||
|
||||
The HTML loads the class-based script after defining both buttons.
|
||||
|
||||
\begin{minted}{html}
|
||||
<button id="blueBtn">Blue</button>
|
||||
<button id="redBtn">Red</button>
|
||||
<script src="script.js"></script>
|
||||
\end{minted}
|
||||
|
||||
\subsection{UML Class Diagram}
|
||||
|
||||
Figure~\ref{fig:color-button-uml} shows the updated object-oriented design.
|
||||
The minus sign indicates private implementation data and the plus sign indicates
|
||||
public operations. The same class is instantiated once for the Blue button and
|
||||
once for the Red button.
|
||||
|
||||
\begin{figure}[htbp]
|
||||
\centering
|
||||
\begin{tikzpicture}[
|
||||
uml/.style={draw=black, rounded corners=1pt, align=left,
|
||||
inner sep=0pt, text width=10.5cm, font=\small}
|
||||
]
|
||||
\node[uml] (class) {%
|
||||
\begin{minipage}{10.5cm}
|
||||
\centering\textbf{ColorButtonController}\\[-2pt]
|
||||
\rule{\linewidth}{0.4pt}
|
||||
\raggedright $-$ button: HTMLButtonElement\\
|
||||
$-$ color: string\\[-2pt]
|
||||
\rule{\linewidth}{0.4pt}
|
||||
$+$ ColorButtonController(buttonId: string, color: string)\\
|
||||
$+$ bind(): void\\
|
||||
$+$ changeBackground(): void
|
||||
\end{minipage}
|
||||
};
|
||||
\end{tikzpicture}
|
||||
\caption{UML class diagram for the class-based two-button website.}
|
||||
\label{fig:color-button-uml}
|
||||
\end{figure}
|
||||
|
||||
\FloatBarrier
|
||||
|
||||
\subsection{Build and Deployment}
|
||||
|
||||
The image was rebuilt as \texttt{color-buttons-app}; container port 3000 was
|
||||
published through host port 8080. The existing container must be stopped and
|
||||
removed before the revised image is deployed with the same container name.
|
||||
|
||||
\begin{minted}{bash}
|
||||
cd color-buttons-app
|
||||
sudo docker build -t color-buttons-app .
|
||||
sudo docker stop color-buttons-app
|
||||
sudo docker rm color-buttons-app
|
||||
sudo docker run -d --name color-buttons-app -p 8080:3000 color-buttons-app
|
||||
sudo docker ps
|
||||
\end{minted}
|
||||
|
||||
The deployed two-button website is
|
||||
\href{http://142.93.193.110:8080}{http://142.93.193.110:8080}. Clicking either
|
||||
button calls its controller instance and changes the page background to the
|
||||
corresponding color.
|
||||
|
||||
\section{Deployment Summary}
|
||||
|
||||
The completed work for Steps 1 through 3 establishes a repeatable cloud deployment
|
||||
workflow: provision the Ubuntu Droplet, install Docker from its official APT
|
||||
repository, build each application image, run the containers with published
|
||||
ports, implement reusable class-based client behavior, and confirm container
|
||||
status with \texttt{docker ps}.
|
||||
Reference in New Issue
Block a user