 Hello! This is Doug Timble coming to you from the City of the Oaks, Raleigh, North Carolina, where rising ocean levels are estimated to transform this landlocked city into a thriving seaport as early as the year 2048. And speaking of 2048, in this video we'll use Eclipse Che to take a look at a C++ implementation of the popular game. The 2048 source code requires some special tooling, so we'll need to create a custom stack before we can build it in Che. By the time we're done here, you'll know how to build a stack that has all the tools you need for your projects. And best of all, you'll be able to waste hours of precious time while pretending to work. You're welcome. We'll start by going to the Che homepage, eclipse.org slash che. Scroll down slightly and click on the Create Free Account button under the SAZ heading. Now scroll down to Create Workspace from a template. The code we're going to build is written in C++, so choose the C++ stack. At this point, you need an OpenShift.io account. If you don't have one, it's free, you can sign up at OpenShift.io. If you have an account and you're not logged in, you'll see the OpenShift.io login screen. Once you're logged in, you'll see this entertaining crane animation as the workspace loads. The system does some initialization, downloads a container image, creates and starts a container based on that image, then loads the necessary code to display the IDE. The first time you run this in your account, Che has to download the container image for the stack that contains the operating system and other tools. When it's done, you'll see this screen. It includes a sample Hello World project that has been cloned from a GitHub repo and Che has run that code. You can see Hello World in the Run tab at the bottom of the screen. But we're here to build a productivity destroying game. To do that, we'll create a new project from the 2048 repo. Go to the Workspace menu and click Import Project. Enter the URL of the repo as shown on the screen here. I named the project 2048, but you can call it anything you like. We'll leave the other options blank. Now click Import to clone the code. Once the code is imported, tell Che that this is a C++ project. That enables syntax highlighting and other nice features. Click Save and we're done. Expand the project and look in the source folder. 2048.CPP has the main method, but game.CPP has most of the logic. Feel free to explore the code all you want. But looking in the project, there's no make file. It's not clear how to build this code, so out of desperation, let's actually read the instructions. The readme file in the repo says we need to create a build directory in the project, then run CMake. So to the terminal we go. Change to the project directory, then make a build directory and change to it. Notice that as you create the directory, the tree view of your project automatically updates itself. Now run CMake. And there is no CMake, which brings us to the subject of custom stacks. What we need to do is take the stack underneath this workspace and add CMake to it. Then we'll create a workspace on top of the new stack and everything should work just fine. But what is the stack underneath this workspace? To find out, go to the Workspaces tab on the far left side of the window. Click the gear icon next to your workspace and you'll see its config file. What we're looking for in the JSON is the recipe field, which you can see here. The workspace is built on top of a container image named Eclipse slash CPP underscore GCC. That's what we'll use in the Dockerfile that builds the new stack. I'm taking a shortcut here and showing you the final Dockerfile. As you can see, all it does is start with the base image and go through a few commands to download and install CMake. If you clone the GitHub repo on your screen, you'll get a file named dockerfile.cmake. That's what I use to build the new stack. Feel free to build it yourself, or as we'll see in just a second, you can simply refer to the image in my quay.io account without building anything. Now that we have our container image, let's go back to Che and create a new stack. Stop the workspace and go to the Stacks tab on the far left. As you would expect, you want to click the Add Stack button. For the recipe, we're going to use the container image built with the Dockerfile we just looked at, so click Dockerfile and enter the URL on your screen. Click OK to create the stack. We'll configure it by giving the stack a name and a description, then we'll edit the machine that runs inside the container. Click the pencil icon to change the name of the machine, then click the arrow next to the machine name to add a few agents to it. You'll need exec, terminal, and workspace API at a minimum. With those changes made, go ahead and click the Save button. If you want, you can test the stack directly, but we'll go ahead and create a workspace based on it. All we did was add CMake to the existing stack so things should work. Go back to the Workspaces tab on the far left and click the Add Workspace button. Give the workspace a name, then select the 2048 stack we just defined. Now click the Add or Import Project button. Click the Get tab and enter the URL of the repo. By the way, if you click GitHub, Che wants to connect to your GitHub account. Since we don't own the repo we're working with, we'll just use the Get tab. Click the Add button to add the repo to your workspace, then click Create. On the panel that pops up, click Open to see the workspace in your browser. After a few seconds, we see that Che is pulling the new image. So now we'll just cut to the chase and show you the running workspace. As you can see, the 2048 repo is cloned into the environment. We know what to do from here. Go to the Terminal tab and follow the instructions from before. Make the build directory. Switch to it. Run CMake and Run Make. CMake creates the Make file and Make creates the object files and links them into an executable. Everything worked, so double-click the Terminal tab to maximize it and type . slash 2048. We'll play a new game with a 4x4 board and use the arrow keys to make the magic happen. It's not as visually flashy as other versions you might have seen, but it's every bit as difficult and addictive. So that's a look at how to build a custom stack. Most of the time you'll be able to use one of the default stacks to do everything you need to do, but if not, building a custom stack is the way to go. In the Docker file, we used a few commands to install the missing tooling. Then we created a workspace based on that stack and finally built the code inside the workspace using the tools we added. If you want to take things a step further, you can use a factory to create a URL from that workspace. You can then share the URL with anyone. When they open the factory URL, their browser will open a new workspace with the exact same environment. In other words, it will work on their machine. We cover factories in another video, but they're just another part of what makes Chase so powerful. For the Red Hat Developer Program, this is Doug Tidwell saying may all your bugs be shallow. Cheers.