Cloud Run now supports deploying directly from source with a single CLI command gcloud run deploy
. Source code is uploaded to Cloud Build, which uses GCP Buildpacks or an included Dockerfile to build a container. The result is pushed to Artifact Registry and deployed to Cloud Run. You can read more about it in deploying from source code docs.
Take a look at the service we already created in
helloworld/csharp/7.0 folder. It's a .NET app and it
doesn't have a Dockerfile
.
Inside the source folder:
SERVICE_NAME=helloworld-dotnet
REGION=us-central1
gcloud run deploy $SERVICE_NAME \
--source . \
--allow-unauthenticated \
--region $REGION
This uploads sources to Cloud Build, uses Buildpacks to build a container and then deploy to a Cloud Run service.
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 7.0!