DAY 30 🌀️ Weather App (Dockerized Flask + Nginx)

Ritesh SinghRitesh Singh
2 min read

A simple weather app built with Flask and served via Nginx using Docker Compose. Enter a city name and get real-time weather data fetched from the OpenWeatherMap API.

πŸ“‚ Project Structure

weather-app/
β”‚
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ app.py               # Flask app
β”‚   └── requirements.txt     # Python dependencies
β”‚
β”œβ”€β”€ frontend/
β”‚   └── index.html           # Simple HTML frontend
β”‚
β”œβ”€β”€ nginx/
β”‚   └── default.conf         # Nginx reverse proxy config
β”‚
β”œβ”€β”€ Dockerfile               # Flask Docker image
β”œβ”€β”€ docker-compose.yml       # Docker Compose setup
└── README.md                # Project documentation

πŸš€ Features

  • 🐍 Python Flask backend

  • 🌐 Nginx as a reverse proxy

  • 🐳 Docker + Docker Compose support

  • πŸ”„ Realtime weather data using OpenWeatherMap

  • πŸ’» Clean and simple frontend UI

βš™οΈ Setup Instructions

1. 🧰 Prerequisites

Make sure you have:

  • Docker installed

  • Docker Compose installed

  • An API key from OpenWeatherMap

2. πŸ› οΈ Clone the Repo

git clone https://github.com/yourusername/weather-app.git
cd weather-app

3. πŸ” Configure Environment

Create a .env file in the project root:

API_KEY=your_openweathermap_api_key_here

4. πŸ“¦ Build & Run Containers

docker-compose up --build

Access the app at: http://localhost

5. πŸ§ͺ Example Usage

  • Open the browser.

  • Type Mumbai or New York in the input box.

  • Click Get Weather to see real-time weather.

πŸ“ Tech Stack

ToolPurpose
FlaskPython Web Framework
OpenWeatherMapWeather API Provider
NginxReverse Proxy
DockerContainerization
Docker ComposeMulti-container setup
HTML/CSSFrontend UI

🧹 Cleanup

To stop and remove containers:

docker-compose down

πŸ“Œ Notes

  • For production, use Gunicorn instead of Flask's development server.

  • Add error handling and input validation for better UX.

πŸ™Œ Acknowledgments

πŸ”— Connect with Me

0
Subscribe to my newsletter

Read articles from Ritesh Singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ritesh Singh
Ritesh Singh

Hi, I’m Ritesh πŸ‘‹ I’m on a mission to become a DevOps Engineer β€” and I’m learning in public every single day.With a full-time commitment of 8–10 hours daily, I’m building skills in: βœ… Linuxβœ… Git & GitHubβœ… Docker & Kubernetesβœ… AWS EC2, S3βœ… Jenkins, GitHub Actionsβœ… Terraform, Prometheus, Grafana I post daily blogs on Hashnode, push projects to GitHub, and stay active on LinkedIn and Twitter/X. Let’s connect, collaborate, and grow together πŸš€ #100DaysOfDevOps #LearningInPublic #DevOps