A simple weather application built with Node.js and Express that displays weather conditions for any city. The application includes a complete CI/CD pipeline for automated deployment of the application to AWS EC2 using Docker, with the image automatically built and stored in a private Elastic Container Registry (ECR) repository.
- Enter city name to get current weather conditions
- Displays temperature, weather description, and humidity
- Responsive web interface
- Dockerized application
- Automated CI/CD pipeline with GitHub Actions
- Backend: Node.js, Express.js
- Frontend: HTML, CSS, JavaScript
- API: wttr.in (free weather service)
- Containerization: Docker
- Cloud: AWS EC2, ECR
- CI/CD: GitHub Actions
- Node.js (v18 or higher)
- npm
# Clone the repository
git clone <repository-url>
cd nodejs-weather-application
# Install dependencies
npm install
# Start the application
npm startThe application will be available at http://localhost:4000
# Build Docker image
docker build -t username/weather-app .
# Run container
docker run -p 4000:4000 username/weather-app- AWS Account with ECR repository created
- EC2 Instance with:
- Docker installed
- Security group allowing port 4000
- IAM role or AWS CLI configured
Set these secrets in your GitHub repository:
AWS_ACCESS_KEY_ID- AWS access keyAWS_SECRET_ACCESS_KEY- AWS secret keyAWS_REGION- AWS region (e.g., us-east-1)ECR_REPOSITORY- ECR repository nameEC2_HOST- EC2 instance public IPEC2_USER- EC2 username (ec2-user/ubuntu)EC2_SSH_KEY- Private SSH key for EC2
The CI/CD pipeline automatically:
- Builds Docker image on push to main branch
- Pushes image to AWS ECR
- Deploys to EC2 instance
- Runs application on port 4000
├── .github/workflows/
│ └── deploy.yml # CI/CD pipeline
├── public/
│ └── index.html # Frontend interface
├── server.js # Express server
├── package.json # Dependencies
├── Dockerfile # Container configuration
├── .dockerignore # Docker ignore rules
└── README.md # Documentation
- Open the application in your browser
- Enter a city name in the input field
- Click "Get Weather" or press Enter
- View the weather information displayed
GET /weather/:city- Returns weather data for specified city
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
.png)
.png)
.png)