git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
Move directory.
cd python-docs-samples/run/system-package
Build the docker image.
docker build --tag graphviz:python .
Start the container.
docker run --rm -p 9090:8080 -e PORT=8080 graphviz:python
Access the URL below and check that the image is displayed. (There is a space, but you can leave it as it is)
https://localhost:9090/diagram.png?dot=digraph Run { rankdir=LR Code -> Build -> Deploy -> Run }
#project
export GOOGLE_CLOUD_PROJECT=<PROJECT_ID>
#Raise the container to GCR
gcloud builds submit --tag gcr.io/${GOOGLE_CLOUD_PROJECT}/graphviz
#Deploy to Cloud Run
gcloud beta run deploy graphviz --image gcr.io/${GOOGLE_CLOUD_PROJECT}/graphviz
You can choose which GCP product to use when deploying, but this time select Cloud Run full managed. Since the URL published in the log is displayed, access the following URL based on it and check that the same image as when trying locally is displayed.
https://<SERVICE_DOMAIN>/diagram.png?dot=digraph Run { rankdir=LR Code -> Build -> Deploy -> Run }
You can also check the deployed endpoints from the Cloud Run management screen of the GCP console.
If this is left as it is, the deployed application will continue to run and it will cost money, so delete it. You can delete the endpoint from the Cloud Run management screen, so delete it. Also, if there is a repository on GCR (Google Container Registry), you may be charged for storage, so delete that as well if you are concerned.
I misunderstood that it was for a more complicated environment, but in the tutorial, I found it convenient to easily execute and release even a small application with only a Dockerfile and a single script. Since the environment can be set freely with the Dockerfile, if you want to finely modify the environment where the application is placed, or If you want to use it other than GCP, that is, if you are assuming multi-cloud, I thought that Cloud Run would be good. However, if you are accustomed to GAE, I feel that GAE 2nd is almost done.
Recommended Posts