weather-webapp

DevOps: CI/CD pipeline for Python weather web app

View on GitHub

Weather WebApp

A simple weather web app built with Python, using Flask, Nginx and Gunicorn. CI/CD pipeline done with GitHub Actions.

Table of Contents

Features

Technologies Used

Installation

To run this project locally, follow these steps:

  1. Clone the repository:
    git clone https://github.com/niv-devops/weather-webapp.git
    cd weather-webapp
    
  2. Active env, install dependencies, run application

    cd existing_repo
    . .venv/bin/activate
    pip install --break-system-packages --user <dependency>
    python3 weather.py
    
  3. Install dependencies:

    python -m pip install --upgrade pip
    pip install -r requirements.txt
    
  4. Set up environment variables as needed (e.g., API keys for weather services).

Usage

To run the application locally, use the following command:

gunicorn --bind 0.0.0.0:5000 wsgi:app

You can then access the application at http://localhost:5000.

Running Tests

To run the tests, execute:

pytest tests/

Docker

To build and run the application using Docker, follow these steps:

  1. Build the Docker image:
    docker build -t weather-webapp .
    
  2. Run the Docker container:
    docker run -p 5000:5000 weather-webapp
    

Continuous Integration

This project uses GitHub Actions for CI/CD. The pipeline includes:

Pipeline Steps

  1. Test: Runs all tests and checks for code quality.
  2. Build: Builds the Docker image and pushes it to the GitHub Container Registry.
  3. Monitor: Sends notifications to a Slack channel regarding the pipeline status.

GitLab additional options

cd existing_repo
git remote add origin http://3.122.61.221/niv/webapp.git
git branch -M main
git push -uf origin main