{"id":16143178,"url":"https://github.com/johnbedeir/gcp-cloud-run","last_synced_at":"2025-04-06T19:24:58.423Z","repository":{"id":215386110,"uuid":"738808073","full_name":"johnbedeir/GCP-Cloud-Run","owner":"johnbedeir","description":null,"archived":false,"fork":false,"pushed_at":"2024-01-04T05:08:24.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-13T01:29:11.171Z","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/johnbedeir.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}},"created_at":"2024-01-04T05:05:34.000Z","updated_at":"2024-01-04T05:06:21.000Z","dependencies_parsed_at":"2024-01-04T06:22:11.397Z","dependency_job_id":null,"html_url":"https://github.com/johnbedeir/GCP-Cloud-Run","commit_stats":null,"previous_names":["johnbedeir/gcp-cloud-run"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnbedeir%2FGCP-Cloud-Run","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnbedeir%2FGCP-Cloud-Run/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnbedeir%2FGCP-Cloud-Run/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnbedeir%2FGCP-Cloud-Run/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnbedeir","download_url":"https://codeload.github.com/johnbedeir/GCP-Cloud-Run/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247536934,"owners_count":20954850,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-10-10T00:08:48.203Z","updated_at":"2025-04-06T19:24:58.398Z","avatar_url":"https://github.com/johnbedeir.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Deploying Flask App on Google Cloud Run\n\n\u003cimg src=cover.png\u003e\n\n### Prerequisites\n\n- A Google Cloud Platform account.\n- Google Cloud SDK installed on your local machine.\n- Docker installed on your local machine (for building the container image).\n\n### Steps\n\n1. **Prepare Your Application:**\n\n   - Ensure your Flask application is in a file named `main.py`.\n   - Create a `requirements.txt` file in the same directory as your `main.py`, listing all the dependencies.\n\n2. **Containerize Your Application:**\n\n   - Create a `Dockerfile` in the same directory as your `main.py`. A basic example of a Dockerfile for a Flask application is:\n\n3. **Build Your Container Image:**\n\n   - Build the Docker image and tag it for uploading:\n     ```\n     docker build -t gcr.io/PROJECT_ID/my-flask-app .\n     ```\n   - Replace `PROJECT_ID` with your actual GCP project ID.\n\n4. **Push Your Container Image to Container Registry:**\n\n   - Push the image to Google Container Registry:\n     ```\n     docker push gcr.io/PROJECT_ID/my-flask-app\n     ```\n\n5. **Deploy on Cloud Run:**\n\n   - Ensure you have set your GCP project ID:\n     ```\n     gcloud config set project PROJECT_ID\n     ```\n   - Deploy the image to Cloud Run:\n     ```\n     gcloud run deploy --image gcr.io/PROJECT_ID/my-flask-app --platform managed\n     ```\n   - Follow the prompts to specify the service name and region. Allow unauthenticated invocations if needed.\n\n6. **Access Your Application:**\n   - Once the deployment is successful, Cloud Run will provide a URL to access your application.\n\nTo remove or delete the deployment of your application from Google Cloud Run, you can follow these steps:\n\n### Delete the Cloud Run Service\n\nFirst, you'll need to delete the specific Cloud Run service where your application is deployed. You can do this using the Google Cloud Console or the `gcloud` command-line tool.\n\nUsing `gcloud`, the command to delete a service is:\n\n```sh\ngcloud run services delete SERVICE_NAME --platform managed\n```\n\nReplace `SERVICE_NAME` with the name of the service you want to delete.\n\nThis command will prompt you to confirm the deletion. Once confirmed, it will remove the service and stop serving your application.\n\n### Remove the Container Image\n\nIf you also want to remove the container image from the Google Container Registry, you can do so through the Google Cloud Console or using `gcloud`:\n\n```sh\ngcloud container images delete gcr.io/PROJECT_ID/my-flask-app --force-delete-tags\n```\n\nReplace `PROJECT_ID` with your actual GCP project ID and `my-flask-app` with the name of your Docker image.\n\nThis command will delete the container image and its tags from your Container Registry.\n\n### Delete the GCR Repository\n\n```\ngcloud container images list --repository=gcr.io/PROJECT_ID\n```\n\n### Notes\n\n- Make sure you replace `PROJECT_ID` with your actual Google Cloud project ID in the commands.\n- The first deployment might take a bit longer as it involves setting up the Cloud Run service.\n- For more detailed information, refer to the [Google Cloud Run Documentation](https://cloud.google.com/run/docs).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnbedeir%2Fgcp-cloud-run","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnbedeir%2Fgcp-cloud-run","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnbedeir%2Fgcp-cloud-run/lists"}