Google provides great continuous integration and deployment tools. What these allow you to do is link github repositories to google cloud so that when the repo is updated, those changes get pulled and automatically deployed on google infrastructure.
- Go to Cloud Run at https://console.cloud.google.com/run
- Create a Service
- Select
Continuously deploy new revisions from a source repositoryand connect your repo'smainbranch - Choose compute and memory appropriate for task
- Allow unauthenticated invocations
- Default everything else
The best way to do this is to go to the cloud build app at https://console.cloud.google.com/cloud-build/ and watch the history. It's using the history that you can find out what errors occur during the build, if any.
Unlike a virtual machine, you can't just SSH into a container on Cloud Run. Instead, you can use the logs for the container at https://console.cloud.google.com/run. Anything that you print to console in your app will show up in these logs along with all other information you'd typically see printed to console. This can be very helpful in debugging.
Google charges you to build new containers and to run the container.
The end result is that when up push a change to your repos main branch, the following process will be triggered:
- Cloud Build will execute the Dockerfile in the repo to build a container
- If the container build is successful, Cloud Run will deploy that container
- The container's public URL can be found by clicking on the cloud run name
- If you go to this URL, all your flask API endpoints will be available in your main.py app