Install Drupal on Google Cloud Run | GCP | Container Registry
Updated: Jan 28
Prerequisites:
You will need the following items to complete this tutorial.
A Drupal image in Google Container Registry.
A Cloud SQL Instance up and running with MySQL 8.0.
A Domain (Registered in any hosting provider).
Step - 1. Add the Drupal image to Container Registry.
Select or create a Google Cloud project from the project selection page in the Google Cloud Console.
Make sure your Cloud project's billing is turned on.
Allow the Container Registry API to be used.
Navigate to the container registry in the Google cloud console and open cloud shell access to pull the Drupal from the docker. Lastly, push the portainer image to the container registry using the following commands.
Syntax:
docker pull drupal
docker tag drupal gcr.io/<project-id>/drupal
docker push gcr.io/<project-id>/drupal
Example:
docker pull drupal
docker tag drupal gcr.io/elegant-canto-331917/drupal
docker push gcr.io/elegant-canto-331917/drupal

To learn more about container registry pulling and pushing images. Visit the link here.
To learn more about deleting an image from the container registry, visit the link.
Step - 2. Create a Cloud SQL Instance with MySQL.

In the Console, Navigate to Cloud SQL, Create a new instance with MYSQL version 8.0, add "0.0.0.0/0" under Authorized networks and create the instance.

Lastly, In the Cloud SQL interface, Navigate to Databases and create a new database for Drupal.
Step - 3. Install Drupal on Cloud Run.
Navigate to the Cloud Run interface in the Google cloud console and click on the "Create Service" option to deploy the drupal.
Choose the "Deploy one revision from an existing container image" option in the create service interface and select the drupal image from the container registry.

Then, type the service name and choose the region and specify the CPU allocation, pricing and auto-scaling options. Also, select the "Allow all traffic" option in the ingress and select the "Allow unauthenticated invocations" in the Authentication.
Lastly, Expand the "Container, Variables & Secrets, Connections, Security" option and type "80" in the container port under the container tab.
Finally, click on the "create" option to deploy the drupal.

Step - 4. Setting up a custom domain.
Navigate to the Cloud Run interface and click on the "Manage Custom Domains" option,
Click on the "Add Mapping" option in the Manage Custom Domains interface to point to your custom domain.

Select the service to which you're mapping the custom domain from the Add Mapping interface.
Enter your domain name and click on continue to verify ownership of the domain.
Unless you bought your domain from Google, you must prove ownership before using it.
In case, If you have already verified the ownership of the domain, choose the domain from the "Select a verified domain" drop-down list and type the subdomain name in the "Specify Subdomain" field or leave it to a blank to point to the root domain.

Then, click on the "continue" option to update your DNS record at your domain registrar.
Lastly, add a CNAME record in your domain DNS points to "ghs.googlehosted.com."
Finally, Click on the "Done" option in the add mapping interface.

Once the domain mapping is completed, proceed with the initial drupal setup.
Step - 5. Drupal Initial Setup
To begin the initial setup, type the URL in the browser. Then, select your prefered language and installation profile.

In the Setup Database interface, choose the database type to MySQL.
Type your database name in the Database Name field, which is added earlier in the Cloud SQL.(Refer Step -2)
In the Database username field, type root(default username for Cloud SQL instance)
In the Database Password field, type your CloudSQL instance Password.
Then, Expand the Advanced options sections, add your Cloud SQL Public IP Address in the Host field, and Save and Continue to proceed to the next step.
Finally, type your site configuration and administrator credentials and complete the setup.

Conclusion
Here are some recommended tips and tricks.
How to Create a PostgreSQL instance.