FOX is a simple, single-page web application that presents fun facts of the Metal Gear Solid saga. It is built with Flask and designed with a focus on modern DevOps practices, including containerization, CI/CD, and monitoring.
- Single-page app with a Metal Gear theme.
- Built with Python and the Flask micro-framework.
- Exposes application metrics for Prometheus monitoring.
- Fully containerized with Docker and Docker Compose for easy deployment and scalability.
- Automated CI/CD pipeline using GitHub Actions for building and deploying the application.
- Backend: Python 3, Flask
- Frontend: HTML, CSS, JavaScript
- Containerization: Docker, Docker Compose
- CI/CD: GitHub Actions
- Monitoring: Prometheus
The project consists of two main containerized services managed by Docker Compose:
- Flask App: The core web application that serves the trivia page and exposes a
/metricsendpoint. - Prometheus: A monitoring service configured to scrape the metrics from the Flask application.
The entire deployment process is automated through a CI/CD pipeline, as illustrated below.
graph LR
User((Developer)) -->|Git Push| Repo[GitHub Repo]
subgraph CI_CD_Pipeline [GitHub Actions]
Repo --> Build[Build & Push]
Build -->|Push Image| Registry[GHCR Registry]
Build --> Deploy[Deploy Stage]
end
Deploy -->|SSH Connection| Server[VM]
subgraph Server_Node [Production Server]
Server -->|Docker Pull| Registry
Server --> Compose[Docker Compose]
subgraph Docker_Stack
Compose --> App[Flask App :8000]
Compose --> Prom[Prometheus :9090]
Prom -.->|Scrape Metrics| App
end
end
- A developer pushes code changes to the
mainbranch of the GitHub repository. - A GitHub Actions workflow is triggered automatically.
- The workflow builds a new Docker image of the Flask application.
- The newly built image is pushed to the GitHub Container Registry (GHCR).
- The 'Deploy' stage establishes an SSH connection to the production server (e.g., an AWS EC2 instance or any VPS).
- On the server, a script pulls the latest Docker image from GHCR and restarts the services using
docker-compose up -d --buildto apply the updates seamlessly.
- The Flask application uses the
prometheus-flask-exporterlibrary to expose a/metricsendpoint. - The Prometheus container is configured via
prometheus.ymlto periodically scrape this endpoint, collecting application-level metrics such as request latency, response counts, and custom business metrics. - The Prometheus dashboard is accessible for visualizing and querying these metrics.
To run this project locally, you need Docker and Docker Compose installed.
-
Clone the repository:
git clone https://github.com/ramoswilly/projectfox.git cd projectfox -
Start the services:
docker-compose up
-
Access the application:
- The application will be available at http://0.0.0.0:8000.
- The Prometheus dashboard will be available at http://0.0.0.0:9090.
