Weather Application Cloud Deployment
Title: Cloud-Based Weather App Deployment using
Docker and AWS EC2
Abbreviated: Dockerized Weather App on AWS Cloud
Introduction
This project demonstrates the complete process of
developing, containerizing, and deploying a Python-based weather application
using Flask, Docker, and AWS EC2. By adopting modern DevOps practices and
container technology, this assignment showcases the transformation from local
development to a globally accessible, scalable cloud deployment. It emphasizes
modularity, reproducibility, and automation, essential principles in
contemporary cloud computing.
Objectives of Part 1
- Design
and develop a Python Flask web application to fetch real-time weather data
from the OpenWeather API based on user-provided city names.
- Set
up the local development environment, managing dependencies
using requirements.txt.
- Establish
a testable application structure with an HTML interface and robust error
handling.
- Validate
the application's performance and accuracy on localhost prior to
packaging.
Objectives of Part 2
- Implement
application containerization by authoring a Dockerfile for the Flask app.
- Build,
run, and test the application inside a Docker container, ensuring
environmental consistency.
- Publish
the finalized Docker image to Docker Hub, enabling global accessibility
and facilitating cloud deployment.
Objectives of Part 3
- Provision
and configure a new AWS EC2 instance using Ubuntu 22.04 LTS for cloud
deployment.
- Install
and configure Docker on the virtual server.
- Pull
the hosted Docker image from Docker Hub and run it as a containerized
service mapped to HTTP port 80.
- Verify
the live application's accessibility via the EC2 instance’s public IP,
confirming deployment success.
Name of Containers Involved and Download Links
|
Container Name |
Download Link |
Purpose |
|
python:3.9-slim |
Base image for building the app |
|
|
narasur/weather-app:v1 |
Custom Flask weather app container |
|
|
Ubuntu 22.04 LTS (EC2 AMI) |
AWS Marketplace |
EC2 cloud OS, Docker host |
Other Software Involved Along With Purpose
- Python
3.x — Flask app development and execution.
- Flask —
Lightweight Python web framework for backend API and HTML rendering.
- Requests —
HTTP client for fetching data from the OpenWeather API.
- VS
Code / Editor — Source code development and Dockerfile authoring.
- Docker
Desktop — Building and managing containers locally.
- Docker
Hub — Image registry for storing/sharing Docker images.
- AWS
EC2 — Cloud infrastructure, hosting the production container.
- AWS
Security Groups — Cloud firewall for controlling inbound network
access.
- OpenWeather
API — External provider of weather data.
- Windows
PowerShell/Terminal — Running CLI commands and establishing SSH
connections.
- SSH
(.pem key) — Secure access to EC2 instances.
Overall Architecture of All Three DAs
Below is a line diagram representing the workflow across
development, containerization, and cloud deployment stages, clearly depicting
all inputs and outputs as required:s3.amazonaws
Line diagram showing full architecture: local Flask app,
Dockerization, AWS deployment
Inputs:
- City
name (user)
- Source
code & Dockerfile (developer)
- Docker
image (container registry)
Outputs:
- Live
weather info in browser (user)
- Deployed
container (cloud)
- Accessible
web app via public IP
Two-Page Description About the Architecture of the DA
The project's architecture is a canonical model for modern
cloud application workflows, embracing separation of concerns and a modular
deployment pipeline:
Development Layer:
All logic for weather fetching and HTML user interaction is coded in Flask,
providing an approachable, scalable backend with HTTP routing. Requests to the
OpenWeather API are crafted with user-provided city names, parsed in Python,
and output as formatted HTML. The local requirements.txt lists all
necessary Python dependencies to ensure the environment can be rapidly
re-created.
Containerization Layer:
Docker enables the "build once, run anywhere" guarantee. By writing a
concise Dockerfile—specifying the python:3.9-slim base image, copying local
files, and installing dependencies—the environment for running the application
becomes fully portable. The Docker Hub registry provides a simple distribution
channel; any compatible host (local or cloud) can instantly pull and run the
image, eliminating manual setup errors.
Deployment and Cloud Layer:
An AWS EC2 instance running Ubuntu LTS acts as the infrastructure host. After
SSH access is established, Docker is installed in minutes, and the application
image is retrieved over the internet from Docker Hub. The container is launched
with a -p 80:5000 parameter, exposing Flask's service directly onto
the instance's HTTP port. Security groups are configured to allow necessary
public traffic. The end result is a resilient, scalable, and instantly
reproducible cloud deployment.
End-to-End Dataflow:
- User
(anywhere, any device) ⇒ Enters city name at live app
URL.
- HTTP
request reaches EC2 server ⇒ Docker forwards to App.
- Flask
backend fetches from OpenWeather API ⇒ Parses data.
- Server
renders response ⇒ Outputs weather info in browser.
The architecture prioritizes:
- Portability: No
infrastructure ties; any compliant Docker host suffices.
- Reproducibility: Code,
dependencies, and configuration are baked into the image.
- Security: EC2
firewall rules restrict access to essential ports.
- Global
reach & instant scaling: Satisfies a real-world cloud use
case.
Procedure - Part 1
(Steps involved in the process with screenshots: please
insert your own original images for each step below.)
- Create
project folder and files
(weather_app, app.py, requirements.txt, templates/index.html)
- Enter
Flask backend and HTML code; insert actual OpenWeather API key.
- Run pip
install -r requirements.txt in Terminal.
- Test
the app with python app.py and http://localhost:5000.
- Verify
weather retrieval and error handling for invalid cities.
Procedure - Part 2
- Install
Docker Desktop and confirm Docker is running (docker --version).
- Write
Dockerfile, specifying base image, working directory, file copy,
dependencies, expose port, and CMD.
- Build
image: docker build -t weather-app .
- Test
locally: docker run -p 5000:5000 weather-app; verify in browser.
- Push
to Docker Hub:
- docker
login
- docker
tag weather-app narasur/weather-app:v1
- docker
push narasur/weather-app:v1
- Confirm
image presence on Docker Hub.
Procedure - Part 3
- Launch
new AWS EC2 Ubuntu 22.04 LTS instance (t3.micro).
- Configure
security group to allow SSH (22) and HTTP (80), optionally TCP 5000.
- Download/use
.pem key; set key permissions via icacls.
- SSH
into EC2 and install Docker (update, install, enable).
- Pull
image: sudo docker pull narasur/weather-app:v1
- Run
container: sudo docker run -d -p 80:5000 --restart always --name
weather-app narasur/weather-app:v1
- Verify
app at http://<ec2-public-ip>; test from multiple devices.
What Modification is Done in the Containers After
Downloading
- No
modifications to the official python:3.9-slim base image.
- Custom
container narasur/weather-app:v1 is built from source (code +
dependencies).
- Dockerfile
sets working directory, port, install commands, and Flask run statement.
- On
EC2, the container is assigned the --restart always policy and
exposed on port 80.
Docker Hub Link of Modified Container
- Docker
Hub: https://hub.docker.com/r/narasur/weather-app
What are the Outcomes of Your DA?
- Full-stack
app development, containerization, and live cloud deployment demonstrated.
- Docker
Hub enables rapid, reproducible launches globally.
- Secure,
production-style cloud setup employing best practices.
- Live
web app accessible from anywhere, real-time weather data validated.
- Developed
skills in troubleshooting, DevOps, and cloud configuration.
Conclusion
This DA showcases a transformation from local app coding to
full cloud enablement, leveraging Docker for portability and AWS for public
availability. The project reinforces modern DevOps techniques essential for
today’s scalable, automated deployments and highlights how infrastructure,
code, and external data can be integrated into a reproducible, production-grade
pipeline.
References and Acknowledgement
- Docker
Hub - Maintainers of the python:3.9-slim base image and
open Docker documentation.
- VIT
SCOPE - Cloud Computing course, Autumn Semester.
- IITB
Docker Tutorial - https://spoken-tutorial.org/coursepage.php?course=Docker
- OpenWeather
API & Team for providing free and reliable weather
data: https://openweathermap.org/api
- AWS for
Free Tier EC2 and documentation.
- Faculty,
friends, parents, and reviewers for guidance, support, and
testing assistance.
Comments
Post a Comment