Take note of the new Dockerfile in the application's root directory. We've pre-written it for you. But we've copied it here too, go through each line and read the corresponding comment.
# Use the official Node 10 image
FROM node:10
# Change directory to /usr/src/app
WORKDIR /usr/src/app
# Copy the application source code
COPY . .
# Change directory to site/
WORKDIR site/
# Install dependencies
RUN npm install
# Allow traffic on port 8080
EXPOSE 8080
# Start the application
CMD [ "npm", "start" ]
From the OpenShift console click the user name in the top right corner and select Copy Login Command.
The login command will be copied to the clipboard, in the IBM Cloud Shell, paste that command. For example:
Create a new OpenShift project to deploy our application, call it example-health-ns.
ocnew-projectexample-health-ns
Build your application's image by running the oc new-build command from your source code root directory. This will create a Build and an ImageStream of the app.
Finally, deploy the application by running oc new-app.
ocnew-app-iexample-health
The output should look like below:
$ocnew-app-iexample-health--> Found image 11bff16 (8 minutes old) in image stream "example-health-ns/example-health" under tag "latest" for "example-health"
*Thisimagewillbedeployedindeploymentconfig"example-health"*Port8080/tcpwillbeloadbalancedbyservice"example-health"*Othercontainerscanaccessthisservicethroughthehostname"example-health" * WARNING: Image "example-health-ns/example-health:latest" runs as the 'root' user which may not be permitted by your cluster administrator
-->Creatingresources...deploymentconfig.apps.openshift.io"example-health"createdservice"example-health"created-->Success Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
'oc expose svc/example-health'Run'oc status'toviewyourapp.
Expose the service using oc expose, a route will be created.
ocexposesvc/example-health
Find the application's route by running oc get routes.