Search code examples
laraveldockergcloudgoogle-cloud-rungoogle-cloud-build

How to deploy Laravel 8 google cloud run with google cloud database


Iam looking for help to containerize a laravel application with docker, running it locally and make it deployable to gcloud Run, connected to a gcloud database. My application is an API, build with laravel, and so far i have just used the docker-compose/sail package, that comes with laravel 8, in the development.

Here is what i want to achieve:

  • Laravel app running on gcloud Run.
  • Database in gcloud, Mysql, PostgreSQL or SQL server. (prefer Mysql).
  • Enviroment stored in gcloud.

My problem is can find any info if or how to use/rewrite the docker-composer file i laravel 8, create a Dockerfile or cloudbuild file, and build it for gcloud.

Maybe i could add something like this in a cloudbuild.yml file:

#cloudbuild.yml
  steps:
  # running docker-compose
  - name: 'docker/compose:1.26.2'
    args: ['up', '-d']

Any help/guidanceis is appreciated.


Solution

  • As mentioned in the comments to this question you can check this video that explains how you can use docker-composer, laravel to deploy an app to Cloud Run with a step-by-step tutorial.

    As per database connection to said app, the Connecting from Cloud Run (fully managed) to Cloud SQL documentation is quite complete on that matter and for secret management I found this article that explains how to implement secret manager into Cloud Run.

    I know this answer is basically just links to the documentation and articles, but I believe all the information you need to implement your app into Cloud Run is in those.