<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Deploying MelodyMates on EC2</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background-color: #f4f4f4;
}
h1, h2 {
color: #003366;
}
pre {
background-color: #e6e6e6;
padding: 10px;
border-radius: 5px;
}
</style>
</head>
<body>
<h1>Deploying MelodyMates on Amazon EC2</h1>
<h2>Server & Container Setup</h2>
<ul>
<li><strong>Cockpit</strong> is the terminal for managing the Amazon EC2 server.</li>
<li>Inside the EC2 server, a Docker container called <strong>melodymates</strong> is running.</li>
<li>The container runs on <strong>port 8404</strong>.</li>
</ul>
<h2>Understanding Docker</h2>
<ul>
<li>A <strong>container</strong> is a virtual computer running our backend server.</li>
<li>When a request reaches the EC2 server on port 8404, <strong>NGINX</strong> routes it to our container.</li>
<li>NGINX identifies the container based on the unique port.</li>
<li>An <strong>image</strong> is the blueprint for the virtual computer (container).</li>
<li>The container runs based on this blueprint.</li>
</ul>
<h2>Docker Commands</h2>
<pre>
docker-compose down # Stops and removes the container (not the image)
docker-compose build # Creates a new Docker image (blueprint)
docker-compose up # Runs the container on port 8404
</pre>
<h2>How Requests Work</h2>
<ul>
<li>When a request is made to the <strong>DNS</strong> (e.g., melodymates.stu.nighthawkcodingsociety.com), it routes to the EC2 server.</li>
<li>NGINX forwards the request to the correct container.</li>
<li>The container processes the request and returns JSON data.</li>
<li>NGINX then sends this response back to the client.</li>
</ul>
<h2>Understanding URLs & PythonURI</h2>
<ul>
<li><strong>DNS</strong>: Converts an IP address into a human-friendly domain name.</li>
<li><strong>PythonURI</strong>: A variable in the frontend that references the server’s URL.</li>
<li>Requests flow from <code>8887</code> (local development) to <code>8404</code> (production).</li>
<li>A <strong>URI</strong> is an endpoint (URL) that the frontend interacts with.</li>
</ul>
</body>
</html>
Deployment Blog
Blog for AWS Deployment