Foundation

My VOD Platform, a development journey

Your project’s foundation

From the original idea, how do you get started ? You might want to do some research first, mainly to see if anyone else had the same idea. Or maybe to find some technical solutions that you did not know about. In my case, the research had been done before hand, and this it what gave me the idea.

Once your mind is ready to start working, once you have enough visibility on which way to go, you need to start with the foundation: what architecture, database, language, tools…

The idea

My idea is to build a platform where users can handle their own video library, live stream and photo gallery. I know this is a project I am able to build, I haven’t find a solution that allows me to do all of this at once, and I also know that I will be using it to share my photos and videos with my family. These are good reasons for me to get started: I have a need, an audience and a capable team.

I know that I want to use Angular for the front end since I master it, PHP because it is easy enough for a project like this, Laravel seems a good option to build an application faster and I know it well. On top of that, I will need Nginx, RTMP and a database, probably MySQL.

Let’s get started!

I would usually use a pre-built solution like MAMP to focus only on the code, and deal with the server side when the project is done, but that is a bit of an outdated thinking. Nowadays, you would use Docker to set everything up and run everything with one command. The obvious advantage of that is that I only need to pull my code once to be able to run the application. Oh, it might not be optimised for performance yet, but it will eventually come.

Recent Comments

Docker-compose file

Defining and running multi-container Docker applications

Docker compose file

Docker Compose works with docker-compose.yml files. Create the file at the root of your project.
This file will be used to define the different containers we want to use (aka services), which image to use, what ports to open…

Here is a minimal version of a docker-compose file that includes php :

version: '2'
services:
php:
image: php:7-fpm

To set everything up, run docker-compose up in your project’s root folder. This will build everything required by the php :7-fpm machine, then run it. The building part will be done only once, then will be cached for the next time.

Expect a few minutes to install the image.

Adding Nginx

What we have defined here is a list of services, when the image is the name of the docker image to use to build the container. If we want to add Nginx to this services, we would create another block using image : nginx :

version: '2'
services:
php:
image: php:7-fpm
nginx:
image: nginx

Directly under services, write your container ID. You can name it as required, not necessarily php or nginx. You can override this name by using the directive « container_name ». It can come handy when you need to execute any command in your container since you need to type his name.

That would be enough to have nginx and php side by side, but far from what we want to achieve. We do not want to use a default nginx machine, but we want a specific github repository. And we need nginx and php to be able to communicate together to be able to display php pages.

Adding the NGINX RTMP module

The directive build allow you to use a specific github URL to build an image.
Edit your docker compose file to replace the image with the build (git) url :

Stop Docker if it is running by running docker-composer down and re-run docker-compose up
The application is now pulling the GIT repository and running the instructions that are in the docker file (building nginx with rtmp, hls, ffmpeg…).

When this has fully ran, congratulations: you now have PHP7.0 and NGINX RTMP running side by side !

Opening the ports:

Yes… But if you try to reach your localhost, nothing happens because the port aren’t open. You can use the ports directive to map your local port to your container’s port:

Try to reach http://127.0.0.1 now – it works !
If you know how to send a live stream, you can follow the instructions here https://github.com/brocaar/nginx-rtmp-dockerfile to test this out: it should work as well!

Nginx Configuration

What if I want to I override the nginx config so it does not use the default file included in the github url? Well, you will use the volumes directive.

Create a nginx.conf file in your project folder. I inserted mine in conf/nginx.conf, copied the content from the github URL, and edited the ports to my convenience. Once done, edit the docker-compose file as follow:

After building the image, after running the container, your local copy of the nginx.conf is placed in /config/nginx.conf
You can use volumes with folders, which we will require later.

The /config/nginx.conf url is not a standard path but this is how the NGINX from the github is being compiled so we will use this.

Re-run docker-compose up and browse to 127.0.0.1:80. You should see now the default nginx message.

Displaying an php index page

Create a folder in your project’s root called my_app and create an index.php file in it. You can insert this content:

<?php
phpinfo();

Which will be enough to prove that PHP is working.
The first thing we need to do is ensure that nginx has the ability to understand PHP files. Classic PHP-FPM configuration.
Empty the content of your nginx.conf file and paste the following:

Re-run docker-compose up and browse to localhost: voilà! You have displayed your own index page using PHP and NGINX with docker. Congrats!

As I mentioned in the previous post, I have found a nginx rtmp docker image that I can use to run what I need for Live Stream. But I also need PHP7 to run on the side. Let’s use docker-compose to do this.

]]>https://gregduche.com/2016/10/24/vod-platform-development-journey-foundation/feed/1506My VOD Platform, a development journey: the idea.https://gregduche.com/2016/10/20/my-on-demand-platform-a-development-journey-the-idea/
https://gregduche.com/2016/10/20/my-on-demand-platform-a-development-journey-the-idea/#respondThu, 20 Oct 2016 09:51:36 +0000https://gregduche.com/?p=460The post My VOD Platform, a development journey: the idea. appeared first on gregduche.com.
]]>

The idea

My VOD Platform, a development idea.

Building a VOD Platform: the idea.

A while ago, when I was working for Optus, I built a VOD & Video Management System capable of delivering media assets in a secure way to the members of the company. Among other tools, the platform was using Nginx to serve video on demand and live stream.

Working on that project was exciting, but was relying on a premium version of Nginx (Nginx Media Server). To have Live Stream available on all devices, I required to use HLS. We chose to use Nginx Plus, offering this feature and the support.

Yesterday, while I was looking for a way to run Nginx RTMP with Docker, I realised HLS had been released by Rarut as part of his RTMP Module. And, cherry on the cake, someone integrated this module in a Docker repository :

See the Github page for more info. I will detail later here what we are doing here.

Being inspired

That was enough to get me excited. Ideas started to come, good and bad. In a few minutes, the simple tools that are in front of you become a highly sophisticated project in your mind. You have that feeling that it will be easy ; as if at that stage you do not realise that it actually needs labor to come out of your mind. Should you start while you are in this state of mind, it is very likely that you will accomplish a lot in a short amount of time.

It is very similar than when I am writing songs ; the inspiration comes and I feel empowered, possessed by it. Creation comes, quickly, and I have the feeling than someone else has written it. As for the song, if you leave your work unfinished, and come back later, it will be very hard to go on.

This time, I decided to see how far and how fast I could go. Spoiler alert : it is very promising.More from this story shortly.

Notes :If you are interested in Video with Nginx, I highly suggest that your follow Rarut. His work and documentation make it very easy to understand the tool : https://rarut.wordpress.com

This series of posts intend to share my thoughts, experiences and some technical advice while creating an on demand platform. For a full technical guide, refer to the links I share or leave a comment

If you have developed using Laravel, you know how usefule the dd() function is. It simply allows you to display the content of any given variable in your browser, and to navigate through it by clicking on each item.

I find this super useful when I am creating new features, and this was definitely missing in WordPress, so I created a plugin that is doing this for you.

]]>https://gregduche.com/2016/03/03/debugging-your-variables/feed/1425My new websitehttps://gregduche.com/2015/11/23/my-new-website/
https://gregduche.com/2015/11/23/my-new-website/#commentsMon, 23 Nov 2015 05:37:17 +0000http://gregduche.com/?p=316Hi everyone and welcome aboard! It is a beautiful warm day today and I am excited to announce the opening of my new website. I will use it to showcase my work, post technical notes and reviews, keep you informed… This site has been built using DIVI theme builder, WordPress, Cloudflare and Nginx. Videos displayed […]

It is a beautiful warm day today and I am excited to announce the opening of my new website. I will use it to showcase my work, post technical notes and reviews, keep you informed… This site has been built using DIVI theme builder, WordPress, Cloudflare and Nginx. Videos displayed here are being displayed with NGINX RTMP, and the site has a grade A SSL certificate. I will keep adding new features over the time… keep in touch!

Please be aware the work is still in progress, but I am getting there, eventually…