{"id":24177786,"url":"https://github.com/niv-devops/docker-compose-mysql-webapp","last_synced_at":"2026-06-01T01:31:44.723Z","repository":{"id":270851008,"uuid":"911646766","full_name":"niv-devops/docker-compose-mysql-webapp","owner":"niv-devops","description":"A Docker Compose Web Application with MySQL and Flask","archived":false,"fork":false,"pushed_at":"2025-01-04T15:45:53.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-02T17:13:20.172Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/niv-devops.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-03T14:08:45.000Z","updated_at":"2025-01-04T15:45:56.000Z","dependencies_parsed_at":"2025-01-03T15:29:44.856Z","dependency_job_id":"267e5593-0c32-4a1c-be7f-a66daab77e4a","html_url":"https://github.com/niv-devops/docker-compose-mysql-webapp","commit_stats":null,"previous_names":["niv-devops/docker-compose-mysql-webapp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/niv-devops/docker-compose-mysql-webapp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niv-devops%2Fdocker-compose-mysql-webapp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niv-devops%2Fdocker-compose-mysql-webapp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niv-devops%2Fdocker-compose-mysql-webapp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niv-devops%2Fdocker-compose-mysql-webapp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/niv-devops","download_url":"https://codeload.github.com/niv-devops/docker-compose-mysql-webapp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niv-devops%2Fdocker-compose-mysql-webapp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33756575,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-31T02:00:06.040Z","response_time":95,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-13T04:16:26.509Z","updated_at":"2026-06-01T01:31:44.709Z","avatar_url":"https://github.com/niv-devops.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker Compose - Flask \u0026 MySQL WebAPP\n\nA Docker Compose Web Application with MySQL and Flask, Initializing SQL `office` database with `employees` table and a Flask webapp to fetch and display the data.\nBoth services run as non-root users.\n\n# Table of Contents\n1. [Prerequisites](#prerequisites)\n2. [Getting Started](#getting-started)\n3. [Features](#features)\n4. [Stopping the Application](#stopping-the-application)\n5. [Troubleshooting \u0026 Managing the SQL Database](#troubleshooting--managing-the-sql-database)\n6. [Run on K8s Locally Using Minikube](#run-on-k8s-locally-using-minikube)\n\n## Prerequisites\n- [Docker \u0026 Docker Compose](https://docs.docker.com/engine/install/)\n- [Minikube](https://minikube.sigs.k8s.io/docs/start/?arch=%2Flinux%2Fx86-64%2Fstable%2Fbinary+download)\n\n## Getting Started\n\n1. **Clone the repository:**\n\n   ```bash\n    git clone https://github.com/niv-devops/docker-compose-mysql-webapp.git\n    cd docker-compose-mysql-webapp\n    ```\n\n2. **Create or edit `.env` file in the project's root path** with the following:\n\n    ```\n    MYSQL_ROOT_PASSWORD=\u003cyour-root-password\u003e\n    MYSQL_USER=\u003cnon-root-user\u003e\n    MYSQL_PASSWORD=\u003cnon-root-password\u003e\n    MYSQL_DATABASE=office # Please keep the name as it is\n    ```\n\n    * Note that any change when containers are running should be followed with:\n\n    ```\n    docker compose down\n    docker compose up -d --build\n    ```\n\n3. **Build and start the services** using Docker Compose:\n\n    ```bash\n    docker compose up -d\n    ```\n\n4. **Access the Flask web application** in your browser at:\n\n    ```\n    http://localhost:5000\n    ```\n\n## Features\n\nAn overview on the project's components and dependencies:\n\n1. **Database initialization** - The SQL DB container runs with SQL script `init-db/init.sql` to create the table:\n\n   | ID | Name     | Role                          |\n   | -- | -------- | ----------------------------- |\n   | 1  | Michael  | Regional Manager              |\n   | 2  | Jim      | Sales Representative          |\n   | 3  | Dwight   | Assistant to Regional Manager |\n   | 4  | Toby     | HR                            |\n\n2. **Web Application** - Python application that uses 2 libraries: \n   [Flask](https://pypi.org/project/Flask/) and [mysql-connector-python](https://pypi.org/project/mysql-connector-python/)\n\n## Stopping the Application\n\nTo stop the services, run:\n\n```bash\ndocker compose down\n```\n\n## Troubleshooting \u0026 Managing the SQL Database\n\nTo view and alter users and databases, start with the following commands:\n\n```bash\ndocker exec -it db bash  # Enter the MySQL container\nmysql -u root -p         # Login to MySQL as root\nSELECT User, Host FROM mysql.user;  # List MySQL users\nUSE office;              # Switch to the 'office' database\nSELECT * FROM employees;  # View data in the employees table\n```\n\n## Run on K8's Locally Using Minikube\n\nTo run this project with Kubernetes locally in Minikube cluster, follow these steps:\n\n1. **Start Minikube and configure it to use Docker daemon:**\n\n   ```bash\n    minikube start\n    eval $(minikube docker-env)\n    ```\n\n2. **Create or edit secret.yaml** like the `.env` file, but the values in base64:\n\n    ```\n    echo -n \"example\" | base64\n    echo \"ZXhhbXBsZQ==\" | base64 -d # To decode the text\n    ```\n\n    Example `secret.yaml`:\n\n    ```\n    apiVersion: v1\n    kind: Secret\n    metadata:\n      name: mysql-secret\n    type: Opaque\n    data:\n      MYSQL_ROOT_PASSWORD: cm9vdHBhc3M=\n      MYSQL_USER: c3FsdXNlcg==\n      MYSQL_PASSWORD: c3FscGFzcw==\n      MYSQL_DATABASE: b2ZmaWNl # Please keep the value as it is\n    ```\n\n3. **Apply all K8's manifest files**:\n\n    ```bash\n    kubectl apply -f ./k8s/\n    ```\n\n4. **Check the resources status:**:\n\n    ```\n    kubectl get po\n    kubectl get svc\n    kubectl get secret\n    kubectl get cm\n    ```\n\n5. **Obtain the IP address and access the application** in your browser at:\n\n    ```\n    minikube ip\n    http://\u003cyour-minikube-ip\u003e:30001\n    ```\n    \n6. **Cleanup** - Remove all resources with:\n\n    ```bash\n    kubectl delete -f ./k8s/\n    ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniv-devops%2Fdocker-compose-mysql-webapp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fniv-devops%2Fdocker-compose-mysql-webapp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniv-devops%2Fdocker-compose-mysql-webapp/lists"}