OpenShift CLI: Create a new app
Let's say you're working on a NodeJS app locally and want to test/deploy your app in openshift.
# Login to openshift
oc login https://console.example.com:8443
# Create a new project
oc new-project name-of-project --display-name="Name of the project" --description="A little description of your app"
# Change to your project
oc project name-of-project
# Create a new app
# Labels can be used later to select objects
oc new-app centos/nodejs-8-centos7~. --name name-of-your-app-here --labels='project-admin=your-username,department=your-department'
# Start a new build/deployment
oc start-build name-of-your-app-here --from-dir=. --follow
# Create a URL to access your app
oc create route edge name-of-your-app-here --insecure-policy=Redirect --service=name-of-your-app-here --hostname=my-nodejs-app.example.com
# Apply labels to the route/url
oc label route name-of-your-app-here project-admin=your-username department=your-department
And you can add a Persistent Volume to your application, if you need one with something like:
# Create and add a Persistent Volume
oc set volume dc/name-of-your-app-here --add --name=storage --type='persistentVolumeClaim' --claim-class='standard' --claim-name='storage' --claim-size='10Gi' --mount-path=/var/www/html
And now you should be able to access your project at the link: my-nodejs-app.example.com.
Every time you make an update, just run oc start-build name-of-your-app-here --from-dir=. --follow, give it a few seconds and check the changes at my-nodejs-app.example.com...
Here, we're using centos/nodejs-8-centos7 image for our NodeJS project. If you're working on a python, apache or php project, you can use centos/python-36-centos7, centos/httpd-24-centos7 or centos/php-71-centos7 respectively. You can find more image builders under https://hub.docker.com/u/centos/ for your project
Don't forget to visit https://hub.docker.com/r/centos/nodejs-8-centos7/ for more settings/environment variables that you can use.