Logo

dev-resources.site

for different kinds of informations.

Building a Weather Dashboard with Docker and AWS S3

Published at
1/6/2025
Categories
awschallenge
nbadevopschallenge
cloud
docker
Author
mayhrem
Author
7 person written this
mayhrem
open
Building a Weather Dashboard with Docker and AWS S3

Hey Coders! In this blog post, we'll walk through the contents of a repository that demonstrates how to build a weather dashboard application using Docker and AWS S3. This application fetches weather data from the OpenWeather API and saves it to an AWS S3 bucket. Let's dive into the details!

Here's my github repository, feel free to check it: weather-app

If you want to connect follow me on Github: Rene-Mayhrem

Repository Structure

Here's an overview of the repository structure:

weather-dashboard/
ā”œā”€ā”€ src/
ā”‚   ā”œā”€ā”€ __init__.py
ā”‚   ā””ā”€ā”€ weather_dashboard.py
ā”œā”€ā”€ .env
ā”œā”€ā”€ .gitignore
ā”œā”€ā”€ Dockerfile
ā””ā”€ā”€ README.md
Enter fullscreen mode Exit fullscreen mode

Key Files and Their Purpose

1. init.py

This file serves as the entry point for the application. It imports and calls the main function from weather_dashboard.py, ensuring the application runs when the Docker container starts.

from weather_dashboard import main

if __name__ == "__main__":
    main()
Enter fullscreen mode Exit fullscreen mode

2. weather_dashboard.py

This is the main application file. It contains the WeatherDashboard class, which handles fetching weather data from the OpenWeather API and saving it to an AWS S3 bucket. The class also includes methods for creating the S3 bucket if it doesn't exist and saving weather data to the bucket.

3. .env

This file contains environment variables required by the application, such as the OpenWeather API key and AWS credentials. It ensures sensitive information is not hard-coded into the application.

OPENWEATHER_API_KEY=your_openweather_api_key
AWS_BUCKET_NAME=weather-dashboard-${RANDOM}
AWS_ACCESS_KEY_ID=your_aws_access_key_id
AWS_SECRET_ACCESS_KEY=your_aws_secret_access_key
AWS_DEFAULT_REGION=your_aws_default_region
Enter fullscreen mode Exit fullscreen mode

4. .gitignore

This file specifies which files and directories should be ignored by Git. It includes entries for the

.env

file, Python cache directories, and other unnecessary files.

.env
__pycache__/
*.zip
test/
data/
Enter fullscreen mode Exit fullscreen mode

5. Dockerfile

The Dockerfile defines the steps to build a Docker image for the application. It installs the necessary dependencies, copies the application code, and sets the command to run the application.

FROM python:3.9-slim

WORKDIR /app 

COPY requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt

# Install AWS CLI
RUN apt-get update && apt-get install -y awscli

COPY .env .
COPY src/ ./src  

CMD ["python", "src/__init__.py"]
Enter fullscreen mode Exit fullscreen mode

6. README.md

The README file provides detailed instructions on how to set up and run the application. It includes sections on prerequisites, setup steps, usage, AWS configuration, and resources for further reading.

Setting Up the Application

To set up the application, follow these steps:

  1. Clone the repository:

    git clone https://github.com/Rene-Mayhrem/aws-weather-app.git
    cd weather-dashboard
    
  2. Create a .env file with your OpenWeather API key and AWS credentials.

  3. Build the Docker image:

    docker build -t weather-dashboard .
    
  4. Run the Docker container:

    docker run --name aws-app weather-dashboard
    

Conclusion

This repository provides a comprehensive example of how to build a weather dashboard application using Docker and AWS S3. By following the setup instructions, you can easily fetch weather data and save it to an S3 bucket. The repository structure and detailed documentation make it easy to understand and extend the application for your own needs.

Feel free to comment and discuss.

awschallenge Article's
30 articles in total
Favicon
Query Data with DynamoDB
Favicon
Top 10 Reasons to Learn AWS in 2025
Favicon
Dante's Mirror - A Quantum Leap For Perception
Favicon
What is AWS? A Beginner Guide!ā˜ļø
Favicon
MiniProject ā€” Detect Faces by Using AWS Rekognition!
Favicon
How I Passed the AWS Certified AI Practitioner Exam ??
Favicon
What is Amazon Rekognition?
Favicon
AWS ECR Made Easy: Securely Store and Manage Your Container Images
Favicon
aws-zero-to-hero : DAY-1
Favicon
10 Proven Strategies to Succeed as an AWS Solution Architect in 2025
Favicon
What is the difference between NAT Gateway & Internet Gateway? šŸ¤”
Favicon
Best AWS Training in Delhi for [ Latest 2025 ]
Favicon
AWS Global Infrastructure: Availability Zones, Regions and Edge Locations.
Favicon
30days DevOps-challenge
Favicon
Terminology from Software Development & Operations
Favicon
Building a Weather Dashboard with Docker and AWS S3
Favicon
Battle Royale of AWS Compute Services
Favicon
Leveraging AWS S3 for a Modern Nigerian Lifestyle: A Cloud Storage Solution
Favicon
Automated Alerts for High CPU Utilization: Real-Time Email Notifications with Instance Details
Favicon
Building a Scalable Data Pipeline on AWS
Favicon
šŸš€ Automating Process Monitoring & Restarting with Bash Scripting Day4! šŸ”§
Favicon
aws-zero-to-hero Day4 : AWS RDS, DynamoDB
Favicon
AWS Glue
Favicon
Aws zero-to-hero: Day2 A Deep Dive into Implementing AWS WAF for Unrivaled Web Application
Favicon
Microservices Architecture: Breaking Down Monoliths for Scalability
Favicon
How to Deploy a Multi-Container App in Amazon ECS?
Favicon
AWS Identity and Access Management (IAM) and Amazon MemoryDB Multi-Region
Favicon
AWS Elastic Compute Cloud (EC2)
Favicon
Creating a Static Website with Terraform and AWS S3 - My Learning Journey Continues! šŸš€
Favicon
Setting Up CodeArtifact from the CLI

Featured ones: