|
| 1 | +### Assignment: Building a Simplified Data Application with Docker Compose |
| 2 | + |
| 3 | +#### **Objective** |
| 4 | +The goal of this assignment is to create a data application using **Docker Compose**, incorporating concepts of storage, networking, and multiple interconnected applications. This assignment will also involve initializing a database and deploying monitoring tools (Prometheus and Grafana) to ensure proper application monitoring. |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +### **Assignment Requirements** |
| 9 | + |
| 10 | +#### **1. Application Overview** |
| 11 | +You are tasked with creating a simplified data application with the following components: |
| 12 | +- **Frontend**: A **Streamlit** application for user interaction. |
| 13 | +- **Database**: A **PostgreSQL** database for persistent storage, preloaded with a table and sample data during initialization. |
| 14 | +- **Monitoring**: Deploy **Prometheus** for metrics collection and **Grafana** for visualizing application metrics. |
| 15 | + |
| 16 | +#### **2. Functional Requirements** |
| 17 | +- **Frontend**: |
| 18 | + - Provide a web interface using Streamlit. |
| 19 | + - The interface should allow users to query and visualize data directly from the database. |
| 20 | +- **Database**: |
| 21 | + - Use PostgreSQL with an initialized schema and preloaded data. |
| 22 | + - The database schema should include a sample table (e.g., `users` or `sales`). |
| 23 | +- **Monitoring**: |
| 24 | + - Configure Prometheus to scrape metrics from all running services. |
| 25 | + - Set up a Grafana dashboard to visualize the metrics (CPU, memory, requests, etc.). |
| 26 | + |
| 27 | +#### **3. Technical Requirements** |
| 28 | +- **Docker Compose Configuration**: |
| 29 | + - Use Docker Compose to define and orchestrate all services. |
| 30 | + - Services should include `frontend`, `db`, `prometheus`, and `grafana`. |
| 31 | +- **Networking**: |
| 32 | + - Create a private network for the application. |
| 33 | + - Ensure secure communication between services using the Docker network. |
| 34 | + - Expose necessary ports for external access (e.g., 8501 for Streamlit, 9090 for Prometheus, and 3000 for Grafana). |
| 35 | +- **Storage**: |
| 36 | + - Use volumes for persistent storage of the database and Prometheus data. |
| 37 | + - Ensure that logs and other stateful data are not lost upon container restart. |
| 38 | + |
| 39 | +#### **4. Steps to Follow** |
| 40 | +1. **Database Initialization**: |
| 41 | + - Create a SQL script to initialize the database schema and insert sample data. |
| 42 | + - Mount the SQL script as a volume in the PostgreSQL container. |
| 43 | + |
| 44 | +2. **Frontend Service**: |
| 45 | + - Create a Streamlit application to interact directly with the database. |
| 46 | + - Include features for querying and visualizing data from the database. |
| 47 | + |
| 48 | +3. **Monitoring Setup**: |
| 49 | + - Configure Prometheus to scrape metrics from all running services. |
| 50 | + - Set up a Grafana container with a predefined dashboard to visualize Prometheus metrics. |
| 51 | + |
| 52 | +4. **Docker Compose**: |
| 53 | + - Write a `docker-compose.yml` file to define and manage all services. |
| 54 | + - Include health checks for all services to ensure proper initialization. |
| 55 | + |
| 56 | +--- |
| 57 | + |
| 58 | +### **Deliverables** |
| 59 | +1. A `docker-compose.yml` file defining all services. |
| 60 | +2. A folder structure with: |
| 61 | + - `frontend/`: Contains the Streamlit app. |
| 62 | + - `db/`: Contains the SQL initialization script. |
| 63 | + - `monitoring/`: Configuration files for Prometheus and Grafana. |
| 64 | +3. Documentation (in a `README.md` file) that includes: |
| 65 | + - Setup and deployment instructions. |
| 66 | + - Descriptions of each service and their interactions. |
| 67 | + - How to access the application and monitoring dashboards. |
| 68 | + |
| 69 | +--- |
| 70 | + |
| 71 | +### **Evaluation Criteria** |
| 72 | +- **Completeness**: |
| 73 | + - All components (frontend, database, Prometheus, Grafana) are correctly configured and working. |
| 74 | +- **Code Quality**: |
| 75 | + - Clean and modular code for the frontend. |
| 76 | +- **Docker Knowledge**: |
| 77 | + - Proper usage of volumes, networks, and multi-service orchestration in Docker Compose. |
| 78 | +- **Monitoring**: |
| 79 | + - Prometheus and Grafana are correctly set up and functional. |
| 80 | +- **Documentation**: |
| 81 | + - Clear and concise instructions in the `README.md` file. |
| 82 | + |
| 83 | +--- |
| 84 | + |
| 85 | +### **Bonus Tasks** |
| 86 | +1. Add additional metrics or alerts in Prometheus and visualize them in Grafana. |
| 87 | +2. Use environment variables in `docker-compose.yml` for configuration (e.g., database credentials). |
| 88 | + |
0 commit comments