With the new-app
command you can create applications from source code in a
local or remote Git repository.
The new-app
command creates a build configuration, which itself creates a new
application image from your source code. The new-app
command typically also
creates a deployment configuration to deploy the new image, and a service to
provide load-balanced access to the deployment running your image.
{product-title} automatically detects whether the Pipeline
or Source
build strategy should be used, and in the case of Source
builds,
detects an appropriate language builder image.
To create an application from a Git repository in a local directory:
$ oc new-app /<path to source code>
Note
|
If you use a local Git repository, the repository must have a remote named
|
To create an application from a remote Git repository:
$ oc new-app https://github.com/sclorg/cakephp-ex
To create an application from a private remote Git repository:
$ oc new-app https://github.com/youruser/yourprivaterepo --source-secret=yoursecret
Note
|
If you use a private remote Git repository, you can use the |
You can use a subdirectory of your source code repository by specifying a
--context-dir
flag. To create an application from 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 by
appending #<branch_name>
to the end of the URL:
$ oc new-app https://github.com/openshift/ruby-hello-world.git#beta4
If a Jenkinsfile
exists in the root or specified context directory of the
source repository when creating a new application, {product-title} generates a
Pipeline build strategy.
Otherwise, it generates a Source build strategy.
Override the build strategy by setting the --strategy
flag to either
pipeline
or source
.
$ oc new-app /home/user/code/myapp --strategy=docker
Note
|
The |
If you use the Source
build strategy, new-app
attempts to determine the
language builder to use by the presence of certain files in the root or
specified context directory of the repository:
new-app
Language | Files |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
After a language is detected, new-app
searches the {product-title} server for
imagestreamtags that have a supports
annotation matching the detected language,
or an imagestream that matches the name of the detected language. If a match is
not found, new-app
searches the Docker Hub
registry for an image that matches the detected language based on name.
You can override the image the builder uses for a particular source
repository by specifying the image, either an imagestream or container
specification, and the repository with a ~
as a separator. Note that if this
is done, build strategy detection and language detection are not carried out.
For example, to use the myproject/my-ruby
imagestream with the source in a
remote repository:
$ oc new-app myproject/my-ruby~https://github.com/openshift/ruby-hello-world.git
To use the `openshift/ruby-20-centos7:latest `container imagestream with the source in a local repository:
$ oc new-app openshift/ruby-20-centos7:latest~/home/user/code/my-ruby-app
Note
|
Language detection requires the Git client to be locally installed so that your
repository can be cloned and inspected. If Git is not available, you can avoid
the language detection step by specifying the builder image to use with your
repository with the The The |