Creating an Application From Source Code
The new-app
command allows you to create applications using source code in alocal or remote Git repository.
To create an application using a Git repository in a local directory:
$ oc new-app /path/to/source/code
If using a local Git repository, the repository must have an origin remotethat points to a URL accessible by the OpenShift Enterprise cluster. |
You can use a subdirectory of your source code repository by specifying a--context-dir
flag. To create an application using a remote Git repository and a context subdirectory:
$ oc new-app https://github.com/sclorg/s2i-ruby-container.git \ --context-dir=2.0/test/puma-test-app
Also, when specifying a remote URL, you can specify a Git branch to use byappending #<branch_name>
to the end of the URL:
$ oc new-app https://github.com/openshift/ruby-hello-world.git#beta4
Using new-app
results in a buildconfiguration, which creates a new applicationimagefrom your source code. It also constructs adeploymentconfiguration to deploy the new image, and aservice toprovide load-balanced access to the deployment running your image.
OpenShift Enterprise automatically detects whether theDocker
or Source
buildstrategy is being used, and in the case of Source
builds,detects an appropriate language builder image.
Build Strategy Detection
If a Dockerfile is in the repository when creating a new application,OpenShift Enterprise generates aDockerbuild strategy. Otherwise, it generates aSourcestrategy.
You can specify a strategy by setting the --strategy
flag to eithersource
or docker
.
$ oc new-app /home/user/code/myapp --strategy=docker
Language Detection
If creating a Source
build, new-app
attempts to determine the languagebuilder to use by the presence of certain files in the root of the repository:
Language | Files |
---|---|
| Rakefile, Gemfile, config.ru |
| pom.xml |
| app.json, package.json |
| index.php, composer.json |
| requirements.txt, setup.py |
| index.pl, cpanfile |
After a language is detected, new-app
searches the OpenShift Enterprise server forimagestream tags that have a supports
annotation matching the detected language,or an image stream that matches the name of the detected language. If a match isnot found, new-app
searches the Docker Hubregistry for an image that matches the detected language based on name.
You can override the image the builder uses for a particular sourcerepository by specifying the image (either an image stream or Docker specification) and the repository, with a ~
as a separator.
For example, to use the myproject/my-ruby image stream with the source in aremote repository:
$ oc new-app myproject/my-ruby~https://github.com/openshift/ruby-hello-world.git
To use the openshift/ruby-20-centos7:latest Docker image stream with the source in a local repository:
$ oc new-app openshift/ruby-20-centos7:latest~/home/user/code/my-ruby-app
Creating an Application From an Image
You can deploy an application from an existing image. Images can come from imagestreams in the OpenShift Enterprise server, images in a specific registry orDocker Hub registry, or images in the localDocker server.
The new-app
command attempts to determine the type of image specified in thearguments passed to it. However, you can explicitly tell new-app
whether theimage is a Docker image (using the --docker-image
argument) or an image stream(using the -i|--image
argument).
If you specify an image from your local Docker repository, you must ensure thatthe same image is available to the OpenShift Enterprise cluster nodes. |
For example, to create an application from the DockerHub MySQL image:
$ oc new-app mysql
To create an application using an image in a private registry, specify the fullDocker image specification:
$ oc new-app myregistry:5000/example/myimage
If the registry containing the image is notsecuredwith SSL,cluster administrators must ensure that the Docker daemon on the OpenShift Enterprisenode hosts is run with the |
You can create an application from an existingimagestream and tag (optional) for the image stream:
$ oc new-app my-stream:v1
Creating an Application From a Template
You can create an application from a previously storedtemplate or from a template file, byspecifying the name of the template as an argument. For example, you can store asampleapplication template and use it to create an application.
To create an application from a stored template:
$ oc create -f examples/sample-app/application-template-stibuild.json$ oc new-app ruby-helloworld-sample
To directly use a template in your local file system, without first storing itin OpenShift Enterprise, use the -f|--file
argument:
$ oc new-app -f examples/sample-app/application-template-stibuild.json
Template Parameters
When creating an application based on a template, use the-p|--param
argument to set parameter values defined by the template:
$ oc new-app ruby-helloworld-sample \ -p ADMIN_USERNAME=admin,ADMIN_PASSWORD=mypassword
Further Modifying Application Creation
The new-app
command generates OpenShift Enterprise objects that will build, deploy, andrun the application being created. Normally, these objects are created in thecurrent project using names derived from the input source repositories or theinput images. However, new-app
allows you to modify this behavior.
The set of objects created by new-app
depends on the artifacts passed asinput: source repositories, images, or templates.
Object | Description |
---|---|
| A |
| For |
| A |
| The |
Other | Other objects can be generated when instantiatingtemplates. |
Specifying Environment Variables
When generating applications from a source or animage, you can use the -e|--env
argument to passenvironment variables to the application container at run time:
$ oc new-app openshift/postgresql-92-centos7 \ -e POSTGRESQL_USER=user \ -e POSTGRESQL_DATABASE=db \ -e POSTGRESQL_PASSWORD=password
Specifying Labels
When generating applications from source,images, or templates, youcan use the -l|--label
argument to add labels to the created objects. Labelsmake it easy to collectively select, configure, and delete objects associatedwith the application.
$ oc new-app https://github.com/openshift/ruby-hello-world -l name=hello-world
Viewing the Output Without Creation
To see a dry-run of what new-app
will create, you can use the -o|--output
argument with a yaml
or json
value. You can then use the output to previewthe objects that will be created, or redirect it to a file that you can edit.Once you are satisfied, you can use oc create
to create the OpenShift Enterpriseobjects.
To output new-app
artifacts to a file, edit them, then create them:
$ oc new-app https://github.com/openshift/ruby-hello-world \ -o yaml > myapp.yaml$ vi myapp.yaml$ oc create -f myapp.yaml
Creating Objects With Different Names
Objects created by new-app
are normally named after the source repository, orthe image used to generate them. You can set the name of the objects produced byadding a --name
flag to the command:
$ oc new-app https://github.com/openshift/ruby-hello-world --name=myapp
Creating Objects in a Different Project
Normally, new-app
creates objects in the current project. However, you cancreate objects in a different project that you have access to using the-n|--namespace
argument:
$ oc new-app https://github.com/openshift/ruby-hello-world -n myproject
Creating Multiple Objects
The new-app
command allows creating multiple applications specifying multipleparameters to new-app
. Labels specified in the command line apply to allobjects created by the single command. Environment variables apply to allcomponents created from source or images.
To create an application from a source repository and a Docker Hub image:
$ oc new-app https://github.com/openshift/ruby-hello-world mysql
If a source code repository and a builder image are specified as separatearguments, |
Grouping Images and Source in a Single Pod
The new-app
command allows deploying multiple images together in a single pod.In order to specify which images to group together, use the +
separator. The--group
command line argument can also be used to specify the images that shouldbe grouped together. To group the image built from a source repository withother images, specify its builder image in the group:
$ oc new-app nginx+mysql
To deploy an image built from source and an external image together:
$ oc new-app \ ruby~https://github.com/openshift/ruby-hello-world \ mysql \ --group=ruby+mysql
Useful Edits
Following are some specific examples of usefuledits to makein the myapp.yaml file.
These examples presume myapp.yaml was created asa result of the oc new-app … -o yaml command. |
Example 1. Deploy to Selected Nodes
apiVersion: v1items:- apiVersion: v1 kind: Project (1) metadata: name: myapp annotations: openshift.io/node-selector: region=west (2)- apiVersion: v1 kind: ImageStream ...kind: Listmetadata: {}
1 | In myapp.yaml, the section that defines the myapp projecthas both kind: Project and metadata.name: myapp .If this section is missing, you should add it at the second level,as a new item of the list items ,peer to the kind: ImageStream definitions. |
2 | Add thisnode selectorannotation to the myapp project to cause its podsto be deployed only on nodes that have the label region=west . |
FAQs
Creating New Applications | Developer Guide? ›
Can a person create an app on his own? The answer is Yes. Minecraft and Flappy Bird are prime examples. Both were created by individuals who are highly successful.
How do you create an app development? ›- Get your app idea on paper.
- Build a Native app or a PWA, based on your needs.
- Make your app by selecting the most suitable method for your business.
- Create an app with an app builder (no-code option)
- Test your app on iOS and Android devices.
- Submit and Publish your app on the stores.
Can a person create an app on his own? The answer is Yes. Minecraft and Flappy Bird are prime examples. Both were created by individuals who are highly successful.
How many developers are needed to make an app? ›So at a minimum, any project to create a successful mobile app really needs from 4 to 10 people on the team. For example, we had to allocate 6 developers, one Project Manager, and one Account Manager to help Adventure Aide with their product launch and growth.
How much does it really cost to build an app? ›Mobile app complexity
The average cost of developing a simple app is $5,000 – $50,000. A simple app comes with a set of basic user features such as a login system, user profile facility, dashboard and limited administration. The cost of a medium complex app is $50,000- $120,000.
For starting with Android app development you should have a basic understanding of Java or Kotlin programming language. You can choose any of the two programming languages but you should consider learning Kotlin as Google has declared Kotlin as the official programming language for android mobile app development.
What are 3 parts in the process of designing an app? ›The basic app design process consists of following steps: Setting the scope. User/market research. UX wireframe.
Can I build an app without coding? ›Creating a mobile app without code is easy. If you have experience using website builders like Wix or Squarespace, the app development process using app builders will be very similar. You'll be using a web-based app maker to design and develop your app from scratch.
How do I code an app? ›- Find a good idea.
- Create a soft design.
- Create a prototype.
- Create a hard design.
- Build your app.
- Go through user testing.
- Publish and begin marketing.
The best thing is, in-depth knowledge of mobile programming is not necessary. There are plenty of resources and tools to help you create a successful app, and it doesn't mean handing over your entire project to a third-party app developer.
Can I build my own app for free? ›
App creation is no longer just for professional developers. Now everyone can build mobile apps without programming using a free version of an award-winning low-code app development platform. Alpha Anywhere Community Edition is a free app development software that creates Android apps and iPhone apps with ease.
How to make an app from scratch? ›- 1 - Define your goals. ...
- 2 - Get a problem statement. ...
- 3 - Perform a competitive analysis. ...
- 4 - Decide your launch platform. ...
- 5 - Create (and test) wireframes. ...
- 6 - Map out user journeys. ...
- 7 - Pitch to investors using an app prototype. ...
- 8 - Create an MVP.
Like most other kinds of software development, building an app requires that you know how to code. There are a couple of different ways you can approach this. Arguably the best place to start is deciding which platform you want to work on, with the two major options being Android and iOS.
How do app developers make money? ›Purchases of in-app resources, subscriptions, and freemium upsell are among the highest-earning monetization methods. Transaction fees, online sales, or sponsorships may complement these. Every method has its limitations, pros, and cons, and there is no one-size-fits-all solution.