Page
Build your application from a container image
In the first lesson, you set up your Developer Sandbox environment and built an application from source code. Now it's time to do the same thing with a container image.
In order to get full benefit from taking this lesson, you need to:
- An OpenShift cluster from the Developer Sandbox for Red Hat OpenShift
In this lesson, you will:
- Set up your Developer Sandbox
- Set up a cluster
- Build the application from a container image
Build the application from a container image
To build your application from a container image, switch to the Developer view in your OpenShift dashboard (Figure 8):
Next, select +Add to display the many options available for adding an application to your cluster (Figure 9).
In our case, we are interested in the Git Repository/Import from Git option. Select Import from Git (Figure 10).
You will be prompted to enter a URL that points to a Git repo. This is where things get interesting. OpenShift will copy the repo to an internal storage location, inspect it, and attempt to discern the import strategy to build it.
OpenShift will choose one of the following methods to build the application:
- Option 1: Using the Builder image for the programming language used (i.e., the s2i option).
- Option 2: Using the Dockerfile that is found in the Git repo.
- Option 3: Using the DevFile that is found in the Git Repo.
Again, we’re focusing on Option 1 right now: Using the Builder image and the s2i technology. The Builder image is determined by inspecting the source code and may be .NET, JBoss, Perl, or one of several other options.
Here are some URLs of sample code that you can use for their related languages:
- C# (.NET): https://github.com/redhat-developer-demos/csharp_mvc.git
- Go: https://github.com/redhat-developer-demos/sandbox-go.git
- Node.js: https://github.com/redhat-developer-demos/sandbox-nodejs.git
- PHP: https://github.com/redhat-developer-demos/sandbox-php.git
- Python: https://github.com/redhat-developer-demos/sandbox-python.git
- Ruby: https://github.com/redhat-developer-demos/sandbox-ruby.git
Select the Container images option (Figure 11).
This is the option I use 100% of the time. I like to build and test my images on my PC, then push them to my image registry (quay.io/donschenck). Once I host an image in a registry, it's very simple to get it into OpenShift.
Just like the other two options, the simplest path is to provide the location of the input—an image in this case (Figure 12), and click Create. Yes, it really is that simple.
Is there more?
Yes. Play around. Try things. Break things. Learn more about the Developer Sandbox. Learn more about OpenShift. There is a wealth of knowledge for you to learn within the Red Hat Developer program.