How to run a custom script after deploying to App Engine?

598 views
Skip to first unread message

Bilal Haidar

unread,
Jun 11, 2021, 4:02:45 AM6/11/21
to Google App Engine

Hello
I am using a Cloud Build workflow to deploy my Laravel app.

There is a need to run `php artisan migration` command once the deployment is done.

How can I do that with Google Cloud Build?

Thanks
Bill

Javier (Google Cloud Platform Support)

unread,
Jun 11, 2021, 5:41:08 AM6/11/21
to Google App Engine
I understand your App Engine flex app is already deployed. Please SSH into the VM of an App Engine Flexible instance [1], you can run your custom scripts from there.

Bilal Haidar

unread,
Jun 11, 2021, 5:46:26 AM6/11/21
to google-a...@googlegroups.com
Thanks Javier,
Where is the code usually located inside that VM? I tried but couldn't find it.

Also, is there a way to do so via Cloud Build step? In order to automate everything?

--
You received this message because you are subscribed to a topic in the Google Groups "Google App Engine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-appengine/JTTWNkOLo_A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-appengi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/d0e1e48c-e2d8-4f3f-8e0f-35d0bae200fen%40googlegroups.com.

Javier (Google Cloud Platform Support)

unread,
Jun 11, 2021, 6:17:52 AM6/11/21
to Google App Engine
Please, can you explain what code you are looking for inside the VM? 
Regarding your second question, do you want to run the custom script after or before deployment?
You may find this documentation [1] interesting.

Bilal Haidar

unread,
Jun 11, 2021, 6:55:23 AM6/11/21
to Google App Engine
Thanks, Javier!

  • I want to know where the folder of the app resides inside the instance VM. I SSH the instance, but I cannot find where my app files are.
  • What I'm looking for is to run `php artisan migrate` to migrate my DB inside the container itself.
    • Found this tool: https://github.com/GoogleCloudPlatform/php-tools
    • I tried to make it run from a Cloud Build Step however it doesn't work! We need access to the vendor folder which is not found inside /workspace but rather inside the container itself.
  • My only option left that I can think of is to curl into an endpoint inside my app that will eventually run the migration. Any other option?

Abel (Google Cloud Platform Support)

unread,
Jun 15, 2021, 11:22:25 AM6/15/21
to Google App Engine
Hello Javier,

>Thanks for our message! I’ve been having difficult time understand these concepts.
Do not worry, we are here to assist you.

>I have a step that deploys the app to app engine. This step creates a nested container where it hosts the app inside. 
Could you please attach only the code for this step in your cloudbuild YAML or JSON file?

>I wanted to access data inside the nested container. This is something I can’t do. The gcloud app deploy creates its own container and I cannot access it.
Being in the same step in which the desired container is created you can use bash syntax for manipulating the container's content.

In general, if I want to share data from step to step how do I go about it? 
> Because, after each step, its associated container is destroyed, you can use bash commands for copying files to /workspace. This default volume mounted on /workspace allows you to share data between steps if you orchestrate it correctly in each step.

Kind regards.

Bilal Haidar

unread,
Jun 15, 2021, 5:14:32 PM6/15/21
to google-a...@googlegroups.com
Thanks a lot 

On 15 Jun 2021, at 6:22 PM, 'Abel (Google Cloud Platform Support)' via Google App Engine <google-a...@googlegroups.com> wrote:

Hello Javier,
Reply all
Reply to author
Forward
0 new messages