Creating New Applications | Developer Guide (2023)

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 Sourcebuildstrategy 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
(Video) How to get rich as a solo software developer - The Ultimate Guide

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:

Table 1. Languages Detected by new-app
LanguageFiles

ruby

Rakefile, Gemfile, config.ru

jee

pom.xml

nodejs

app.json, package.json

php

index.php, composer.json

python

requirements.txt, setup.py

perl

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:

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
(Video) Guide To Becoming A Self-Taught Software Developer

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 --insecure-registry flag pointing to that registry.You must also tell new-app that the image comes from an insecure registry withthe --insecure-registry=true flag.

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.

Table 2. new-app Output Objects
ObjectDescription

BuildConfig

A BuildConfig is created for each source repository specified in thecommand line. The BuildConfig specifies the strategy to use, the sourcelocation, and the build output location.

ImageStreams

For BuildConfig, two ImageStreams are usually created: one torepresent the input image (the builder image in the case of Source builds orFROM image in case of Docker builds), and another one to represent theoutput image. If a Docker image was specified as input to new-app, then animage stream is created for that image as well.

DeploymentConfig

A DeploymentConfig is created either to deploy the output of a build, or aspecified image. The new-app command creates EmptyDirvolumes for all Docker volumes that are specified in containers included in theresulting DeploymentConfig.

Service

The new-app command attempts to detect exposed ports in input images. Ituses the lowest numeric exposed port to generate a service that exposes thatport. In order to expose a different port, after new-app has completed, simplyuse the oc expose command to generate additional services.

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
(Video) Android Development for Beginners - Full Course

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|--outputargument 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
(Video) Advanced Prestashop module developer guide crash course

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, new-app uses the builder image as the builder for the source coderepository. If this is not the intent, simply specify a specific builder imagefor the source using the ~ separator.

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: {}
(Video) HTML & CSS Full Course - Beginner to Pro
1In 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.
2Add 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? ›

How to create an app for mobile devices
  1. Get your app idea on paper.
  2. Build a Native app or a PWA, based on your needs.
  3. Make your app by selecting the most suitable method for your business.
  4. Create an app with an app builder (no-code option)
  5. Test your app on iOS and Android devices.
  6. Submit and Publish your app on the stores.
Jul 10, 2023

Can a single developer create an app? ›

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.

What are basics required for app development? ›

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? ›

How to Program an App: Step-by-Step
  1. Find a good idea.
  2. Create a soft design.
  3. Create a prototype.
  4. Create a hard design.
  5. Build your app.
  6. Go through user testing.
  7. Publish and begin marketing.
Jun 11, 2023

Do you need to know coding to make an app? ›

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? ›

How to create an app from scratch: The exhaustive 11-step guide
  1. 1 - Define your goals. ...
  2. 2 - Get a problem statement. ...
  3. 3 - Perform a competitive analysis. ...
  4. 4 - Decide your launch platform. ...
  5. 5 - Create (and test) wireframes. ...
  6. 6 - Map out user journeys. ...
  7. 7 - Pitch to investors using an app prototype. ...
  8. 8 - Create an MVP.
Feb 27, 2023

Does app development require coding? ›

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.

Videos

1. New Developer Guide to Self-Storage: Where Do I Start?
(Trachte Building Systems)
2. Flutter Course for Beginners – 37-hour Cross Platform App Development Tutorial
(freeCodeCamp.org)
3. How to Use Power Apps | Get Started with THIS Tutorial & Create your 1st app
(Leila Gharani)
4. Master Google Maps: Create Amazing Routes in ReactJS - Step by Step Guide!
(Fabio Bergmann)
5. Squarespace Tutorial - 2023 (for Beginners) - Create A Professional Website
(Santrel Media)
6. ☠️😈 A Developer's Guide to Making Project Setup As Difficult As Possible 😈☠️
(Minnestar)

References

Top Articles
Latest Posts
Article information

Author: Catherine Tremblay

Last Updated: 10/23/2023

Views: 5639

Rating: 4.7 / 5 (47 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Catherine Tremblay

Birthday: 1999-09-23

Address: Suite 461 73643 Sherril Loaf, Dickinsonland, AZ 47941-2379

Phone: +2678139151039

Job: International Administration Supervisor

Hobby: Dowsing, Snowboarding, Rowing, Beekeeping, Calligraphy, Shooting, Air sports

Introduction: My name is Catherine Tremblay, I am a precious, perfect, tasty, enthusiastic, inexpensive, vast, kind person who loves writing and wants to share my knowledge and understanding with you.