Symfony is without doubts one of the most popular PHP frameworks. It has amazing flexibility and is written in an applaudable modular fashion. Some Symfony components even power other prominent frameworks like Laravel. Running Symfony is a bit tricky at times, especially the permissions of the cache and logs folder, this blog post demystifies running the Symfony Demo App in a docker container and hosting it serverless on Google Cloud Run.
This post is not going to be a detailed one like the last one about Laravel on Google Cloud Run. If you are fairly new Git or Docker, please do read the above-mentioned post thoroughly.
Before going to the steps, the repo is hosted on my Github and it is open-source of course. It might look insanely easy but we will go through some details after the steps. So let’s get started now:
1. Go to the repo
Navigate to the open-source Github repo. That is a very easy step, isn’t it? :)
Repo with Dockerized Symfony Demo App
2. Click on the Google Cloud button
Then click on the Run on Google Cloud blue button, as shown below:
Click on the button
3. Choose correct settings on Google cloud CLI
After that, given you are logged into your Google account and have Google cloud setup with 1 or more projects, click Proceed. You might need to wait a bit, after that
Then wait for the container to be built and deployed, you can see my process below:
Deploying Symfony Demo app with Google Cloud shell script
If everything goes fine on your Google Cloud Shell, you will see HTTPs URL you can go to in order to see your Symfony demo app running like below:
Symfony Demo app running on Google Cloud Run
One issue with this setup is that data will not be saved if you click around and add new posts. This happens because the data is saved in the SQLite file, as it is not persisted new containers get the old file and you get the same data pushed in the repo.
There are some things you need to consider for this automagic deployment of the Symfony App. Let’s look at what just happened above:
To make the most out of this tutorial, you can fork the repo, add your own button then explore more with it.
Running Symfony entails some tricky configuration :) so the Dockerized version is a breeze to run.
I really believe that Google Cloud Run is a superior product if you know how to dockerize your web app and run it on port 8080 you can get amazing scalability with unparallel ease to make it run.
I would recommend Cloud Run for any pet project or even production application.
Read more at https://geshan.com.np
Create your free account to unlock your custom reading experience.