API to calculate health status based on Body Mass Index (BMI). Live URL https://bmi-api-7kh3wpfy3a-et.a.run.app/ (inactivated)
- Flask 2.0.1
- Flask-RESTful 0.3.9
- Docker
- Google Cloud Run
- Google Artifact Registry
- Google Cloud Build
-
Create a virtual env
python3 -m venv env source env/bin/activate
-
Run installation
pip install -r requirements.txt
-
Run the app
python app/app.py
-
Test the URL http://localhost:5000/?weight=55&height=167.
-
Create docker image
docker build -t bmi-image:latest .
-
Run docker container
docker run -d -p 5000:5000 --name bmi-api bmi-image:latest
-
Test the URL http://localhost:5000/?weight=55&height=167.
-
Activate virtual env
source env/bin/activate
-
Run Test
python app/test_app.py
Create Artifact Registry and Build Trigger in Google Cloud.
-
Fork the repository
-
Install and initialize Cloud SDK
-
Create Artifact Registry
gcloud artifacts repositories create bmi-repo --repository-format=docker --location=asia-southeast2 --description="Docker repository"
-
Create Build Triggers
gcloud beta builds triggers create github --repo-name=bmi-api \ --repo-owner=YOUR_GITHUB_USERNAME \ --branch-pattern=^main$ \ --build-config=cloudbuild.yaml \ --name=bmi-api
-
Create commit to branch
main
in the forked repository to trigger the build, test, and deployment to Cloud Run