Let's deploy a container to a public Cloud Run service.
Cloud Run Button is a fun and easy way of running your code on Cloud Run. You can try it out here to deploy the service in helloworld folder:
Let's go through the steps involved in actually creating and deploying the 'Hello World' service.
Take a look at the service we already created in helloworld/csharp/6.0 folder. It's a .NET app with a Dockerfile
.
In folder where Dockerfile
resides, build the container using Cloud Build and push it to Container Registry:
PROJECT_ID=$(gcloud config get-value project)
SERVICE_NAME=hello-http-container-dotnet50
gcloud builds submit \
--tag gcr.io/$PROJECT_ID/$SERVICE_NAME
REGION=us-central1
gcloud run deploy $SERVICE_NAME \
--image gcr.io/$PROJECT_ID/$SERVICE_NAME \
--allow-unauthenticated \
--platform managed \
--region $REGION
This creates a Cloud Run service and a revision for the current configuration. In the end, you get a url that you can browse to.
You can also see the service in Cloud Run console:
You can test the service by visiting the url mentioned during deployment and in Cloud Run console.
SERVICE_URL=$(gcloud run services describe $SERVICE_NAME --region $REGION --format 'value(status.url)')
curl $SERVICE_URL
Hello World from .NET 6.0!