Laravel 5.6 Template For OpenShift

OpenShift website

Recently I tried OpenShift service.

If you never heard about it, OpenShift is an open source container application platform by Red Hat based on top of Docker containers and the Kubernetes container cluster manager for enterprise app development and deployment.

For short, OpenShift provide a simple hosting solution based on Docker container (and Kubernetes if needed) for your application.

If you’re using their free service, you can only use one project (application) with limited resource. For free service, OpenShift provide 1 GB RAM, 1 GB persistent storage, and 1 GB terminating memory.

This free resource is shared and quota limitation is applicable, so they could terminate the service when you reaching the CPU or memory usage quota.

If you want just to play around, I think it’s not a problem. If you like their service, just subscribe to their service.

Using OpenShift For Laravel Application

Let assume we have an OpenShift account. Registering an account is really easy.

After logged in, just head to the console and choose one of their application template (Docker images). You can also deploy from your previously pushed Docker image to OpenShift private repository.

Fortunately, OpenShift has Laravel with MySQL (persistent) image on their image catalog. This makes our life easier.

OpenShift image catalog

After choosing Laravel and MySQL image, it asks a Git repository for the Laravel application. By default, they will suggest Jacob Lucky’s Laravel example on GitHub.

I found that example is using Laravel 5.0.14, very old! The latest Laravel version is 5.6.15 (as of this article published).

So, I forked the repo, upgraded the Laravel to version 5.6, and made some changes. You can also use (or fork, or do whatever you need) my Laravel example application GitHub repository.

I filled up the form, and pointed the Git repository URL to

You can fill the rest of the form, or just leave it as default. I only filled the form that had an asterisk (*) mark and left the rest intact.

After hitting the Create button, the application is done and ready for action.

Now we can go to the application console.

At the first time, we will see the application build failed.

From the log, I saw the cause of this error. Laravel 5.6 required PHP 7.1 and the PHP used was 7.0.

Let’s fix this by selecting Builds tab from the Builds menu. We will change the PHP base image used by our Laravel application.

Edit the laravel-56 image (the name of the application) by clicking on the name, then select Edit from the Actions on dropdown menu button on the top right.

On the Image Configuration, change PHP image tag to 7.1 or latest. Then save the new configuration. The build will be immediately run after the save.

Congrats, now our Laravel 5.6 application is running successfully.

You can see the example of the running application here:

If you found that link is broken, the application might has reached the limitation quota. Sorry for that.

Enabling TLS Route

If you want to enable TLS for secure connection using HTTPS, go to Routes inside the Applications menu and edit the application name (in my case, laravel-56).

On the Security section, check the Secure route option. Select Passthrough on the TLS Termination and select Redirect on the Insecure Traffic.

We don’t need to upload any certificates or private keys. The application will use OpenShift certificates for securing the connection.