- You have done at least one project with Symfony (of course you are comfortable with PHP and composer)
- You have a good working knowledge of git and Github
- Know a fair bit of docker, maybe even multi-stage build
- Have a working Google cloud account (they give you $300 credit free for 1 yr, no reasons not to have an account)
1. Go to the repo
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
- Choose the project — Choose a project to deploy this application
- Choose the region — Choose a region to deploy this application, I usually choose
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.
So what just happened?
There are some things you need to consider for this automagic deployment of the Symfony App. Let’s look at what just happened above:
- The Symfony Demo app has been dockerized, have a look at this Dockerfile and the Apache config too. The Dockerfile uses multistage build, on stage to install dependencies with composer and another one with Apache to run the application.
- If you want to run it locally, just run docker-compose up then go to https://localhost:8080. 8080 is the required port needed for Google Cloud Run.
- Thanks to the Google Cloud Run button and the Cloud Shell script that does the automagic deployment.
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.