 Hello everybody, this is Grant your friendly open-shift developer evangelist I'm coming at you today from tornado headquarters in North Carolina So what I mean by that there is actually tornadoes going on outside right now So you may be able to hear the the wind in the background, but today And I just wanted to take a few minutes late in the afternoon. It's about four o'clock to Show you guys another video of some of the awesome stuff We've been working on with our new version of our container application platform called open-shift today I'm gonna give a shout out to all the PHP developers out there and show how you can get instant gratification with your PHP projects deployed to Docker containers orchestrated with Kubernetes all using the OpenShift platform. So let's go ahead and get started Today we're gonna be using the open-shift all-in-one image Which is always the latest and greatest upstream version of the open-source project if you don't have it yet Don't worry. All you need to do is go to openshift.org Slash VM and this gives you the instructions to download and run the all-in-one image The only requirements is that you have vagrant in virtual box installed now already have this running So let's skip this and go ahead and log in. I'm gonna log into the platform as my user here and I'm going to go ahead and remember the password. Why not? It's my local open-shift environment now as a PHP developer The first thing I want to do is create a new project and today's video We're gonna be showing code igniter and how you can save your changes and have them automatically show up inside of your Docker container now This is gonna be the same for any framework that you use, but I just created a base GitHub repository with the latest and greatest code igniter framework. So I'm gonna call this code igniter And the display name is code igniter If I can spell it right Project and we're not even gonna give it a description. We're just gonna click on create here now that we have a project We need to decide what type of containers that we want to run that make up our application I'm gonna scroll down. I'm gonna select PHP 5.6 and I'm gonna call this my Ciphp and now it's asking for a git repository URL. So let me hop on over to github real quick And go to slash g shipply that's my github account. I'm gonna click on my repository So I just created this brand new CI open shift repository. I'm gonna click on that. You're probably wondering What's in this? Repository the only thing that's in here is I invented an empty repository I downloaded the latest version of coding nighter and copied it in so I haven't done any other Modifications other than this simple read me file here. So what I want to do is glad grab the repo URL I'm just gonna copy that to my clipboard go back over to my open shift console Paste that in and click on create So what's actually happening under the covers here is that open shift is using our open source project called source to image That's going to take a base PHP 5.6 Docker image It's then going to take that github repository with the PHP source code in it And it's going to run a build of that source code and then create a new Docker image on the fly that contains the PHP runtime as well as your source code. So let's go ahead and go to our PHP Project overview here. We have a build that's running. So that's interesting. Let's take a look at that All right, we can see the build is actually running and what's interesting about this particular build is code igniter uses Composer for dependency management and just to illustrate the beauty of source to image You can see the source to image actually recognizes that for PHP and installs those dependencies Now this will take a couple of minutes like I said while it's building this Docker container on the fly It looks like the container has been built now and it's pushing the image up to the internal open shift registry Okay, it looks like our image has been successfully pushed now And so now that that image is in the Docker registry running inside of open shift Open shift the platform will they'll spin up that container for so let's go back to the overview And we can see that we have one pod running now So let's click on the exposed URL and just take a look at what the application looks like Now if you're familiar with coding nighter, you know, this is just the standard welcome page Okay, so let's go back to the console and Then let's look at how we're going to start developing against this project But we're actually going to be using the Eclipse PHP development environment called PDT Now if you're a net beans or IntelliJ user this process will work exactly the same for you So let's go ahead and go over to our Eclipse environment. You can see I just have an empty workspace here I don't have a project yet. So let's go ahead and create one I'm gonna say new project and I'm going to select PHP project And I'm going to give my project a name and I'm just gonna call it my coding nighter Since we're working with the coding nighter model view controller framework Then I'm going to select to create a project at an existing location And this is where I'm just going to browse to my get source repo that I have cloned locally And it just pops up automatically for me there. So I'm gonna click open and We're using PHP 5.6 all good there We yeah, let's go ahead and enable JavaScript We're just gonna click finish there and here we can see that we have that Application cloned down this basic one. So we can look at the controller here, which is if you're familiar with coding nighter This is what loads that first page here. It loads the welcome message, which is actually a view now Coding nighter is a model view controller framework. So let's go into view and here's the welcome message Okay, so if we scroll down we can see welcome to coding nighter with exclamation point We pop back over to our console click on the link here This is what's driving this message right here and that's what we want to change So let's close a couple of these tabs here go back to our clips So when I said instant gratification what I want to do is set up a clip So anytime I make a change those source files change Changes are also sent over to the Docker container So I can actually use OpenShift as a pure development platform without having to install Apache and and MonPHP and MySQL and MongoDB Postgres whatever your stack includes You can just develop directly against the the cloud platform here And so how do we do that? What we want to do is click on our project and right click on it and go to properties And we want to create a new builder Okay, and so I'm gonna select builders and I'm gonna click on new and we're going to want to run an external program Click on okay there may move the box down for you and we want to give the builder name So we're just gonna call this our sync to OpenShift and then the location is the location of the OC command line tool So what I'm gonna do is just pop open my terminal here real quick and type which OC to get the location of my OC tool and I'm going to copy that and Paste that in here and then for working directory. We want this to be our project directory So I'm just gonna say browse file system and it's smart enough to drop me there by default and Then for the arguments. These are the arguments. We're gonna pass to OC I just want to say our sync dot space Which is dot is represents the current working directory that we just defined and we want to sync it to a specific Container so we have to get that containers name So let's pop back over to the web console real quick Click on our pods here and this is our container name So I'm just gonna copy this to my clipboard hop back over to my Eclipse environment paste that in and then I'm gonna do a colon And then we need to specify the directory that we want to Push our code to and that's gonna be opt apt root slash Source so that is slash opt slash app Dash root slash source SRC and that's all there is to it. I'm gonna click apply on that click ok and We actually I don't actually want all of these other builders to run You can leave them on if you want, but I'm just gonna select them here And click ok so let's go ahead and make a change here. This is the line we want to change Oh, I forgot one thing. Let's go back into our builder So I'm gonna go back into properties select builders like this our sync to open shift click edit And let me move this down again if you click on build options the true magic Happens by selecting all of these boxes and that will ensure anytime we click on save on a file that that command will run So I'll click ok apply that click ok. So now let's make the change so we can say welcome to code igniter running inside of a Docker based container on Open shift 3 and some exclamation points there to watch this down here in the console when I click this save button We're gonna see that it's gonna our sync that file over there We go one file changed welcome message dot PHP if we pop over to our browser again And we refresh this app Boom, there it is Bob's your uncle. That's fantastic stuff. So now you have Full control over your development environment and you can use Open shift and Docker base containers as your true development environment And you don't have to install all this stuff on your local machine. Just use open shift for it Let's go back to the IDE again real quick and a few things I do want to point out here. Okay a couple of gotchas that you may run into this only works For single container based applications Okay, so if you scale up to one or two pods Or sorry if you scale up to four or five six pods It's not gonna change on the one pod that we specified in the our sync command now. That's okay, right because For development you can develop against a single container for rapid application development Now the other gotcha is when I'm making changes in this container if the container goes away I'm gonna have to update my configuration and By that I mean anytime this container goes down and comes back. It's gonna get a different ID So here it's 0997 J So let me illustrate this real quick. Let me go back to the overview. Let me scale this down So I'm gonna scale this down to zero containers and Then let me scale it back up to one and you'll see that a new Container was created now. It's pu in for e So what all you need to do is you decide to do this for whatever reason is get this new container Name copy that hop over to your Eclipse environment and just update that builder Right. It just takes a second and then you know, I'm doing it right now That's how quick it is and I'm just gonna replace this 0977 J with the current one and Done now. I'm back up and running. Okay, it's synced everything over again The other gotcha is that you're still gonna want to use get just like you did So for example, here's my changes that should be running in my container because I just synced it back over again So if I go to overview and click on that we can see that it changed But this is not in my get repository So what you want to do as a developer is just your normal workflow You want to code iterate I get a feature working and then at the end of the day when your features working You want to come into your project here and you can do a get status and we should see This file has changed the welcome message and then you'd want to commit that up to your repository So that's it for this video, I hope you enjoyed it Just showing you how you can quickly use an interpreted language on OpenShift for instant development gratification. Thanks a lot. Bye