39
loading...
This website collects cookies to deliver better user experience
docker --version
ibmcloud --version
In the case that you don't have the above CLIs installed, I would recommend navigating to the links and following the respective Getting Started guides.
git clone https://github.com/mrinasugosh/random-cat-facts-nodejs.git
FROM
instructionDockerfile
must start with a FROM
instruction. The FROM
instruction initializes a new build stage and sets the Base Image for subsequent instructions.FROM node:14.15.1-alpine
app.js
and package.json
files as part of the docker build instructions.COPY app.js .
COPY package.json .
RUN
command to install all packages in package.json that is needed for the app. Then we will use the EXPOSE
command to point to the port that app will be listening on.RUN npm install &&\
apk update &&\
apk upgrade
EXPOSE 3000
CMD node app.js
docker build . -t random-cat-facts:v1
random-cat-facts:v1
docker images
docker run
command pointing the image to the port the app will be listening on:docker run -p 3000:3000 random-cat-facts:v1
curl
command to ping the application.curl -X POST localhost:3000/test
/test
endpoint to test our application and as expected pinging our app does display a random cat fact.us-south
$ ibmcloud login
$ ibmcloud api https://cloud.ibm.com
$ ibmcloud cr region-set us-south
$ ibmcloud target
ibmcloud cr login
ibmcloud cr namespace-add random-cat-facts
docker tag random-cat-facts:v1 us.icr.io/random-cat-facts/random-cat-facts:1
docker push us.icr.io/random-cat-facts/random-cat-facts:1
ibmcloud cr images
@mrinasugosh
) ====39