All right.
We have just agreed that the very thrust to small application and run it using technology as container
and it was the relatively easy all what we did to we actually executed specific file namely Hello de
Jesus using Node interpreter.
That's it.
Now let's create a bit more complicated application with additional NPM package that we will need to
install into our application locally on our computer.
And for that we will use comment from docker container.
Let's do that.
Let's clear terminal and let's move to our visual studio called Project frost and he'll let me close
hello do just file and let's create new for the inside of the node folder for that select load folder
and click on this folder icon and create new folder named express like so and here inside of this folder
let's create new file indexed the Jesus like so in the Lord Jesus and now let's open up web browser
and type here in B Jesus dot com and PM in more just stands for note package manager and using NPM you're
able to install many many different public open source packages and create the applications your obligations
based on those third party packages.
Let's switch here for package gold express.
It is very very popular package.
Let's click on this first link Express and you'll see that this package is the law that more than 11
million times every week let's here scroll down and you'll see how to create very simple Express Web
server.
And let's use those comments.
Let's simply copy all of them from this page.
Copy them.
Go to our IN THE LARGEST file here in Express folder and paste all files like salt and let's adjust
this application a bit.
Let's type here not killer rolled.
Let's type this Express up was executed by node Jesus container inside of the like Sol was suppressing
key combination out option Zi to remove horizontal scrolling and let's save the file and notice that
our application will no listen at port three thousand and that means that we will need to use Port maybe
if we want to connect to our Express Web Celera from outside and we will do that of course in this lecture.
Great let's not try to execute this file using the same approach as we used in the previous lecture
let's go to the terminal and here let's Cydia to express folder because now we allocated ignored folder
we need to move to express folder City to express let's list files here and yes I see single in the
largest file here and let's now use same command as we used before.
Let me go to this comment in history and the let's adjusted and instead of hello de Jesus let's type
in De Jesus and let's try to run this application using the same comment as it used for hello world
application let's press enter and I see error cannot find module Express and the reason for that is
very simple we need theorist don't look at this Express module from NPM and only afterwards run our
application otherwise you'll get such errors module not found and again if I'll go back to this application
in a visual studio called you'll see that we're actually require external module express here is this
light responsible for that and that's why thrust we need to run npm install command for our application
and if I'll try to do it locally on my computer using simply npm install command I'll get commanded
found and VM because there was no no GST or NPM installed on my local computer and that's why we need
some how Iran and install a command using not Jesus dawg our container question how are we able to do
so.
We are able to do so using the same approach as we used in the previous comment in the previous comment.
We have overread read the default comment and here was custom comment that was executed after the start
of this container and no we wanted to run npm install command and for that we don't simply replace this
command note in the Logies with npm install command.
But please note that all those two options will need to remain in place because we need to run in being
install let's say in our local folder on our computer.
Let's try it.
Let me remove node in the genus and type here npm install and let's press enter and now I see some meaningful
output after entering this command and it seems that the Lord container tried to install packages but
do we see running.
No such file or directory not able to open file package the Jason inside of the up folder inside of
the container and that actually means that we need to first initialize our no Jesus project using NPM
in need.
Command and answer or some prompts and afterwards node container will create baggage.
But Jason the file was told it was merely a terminal and the here.
Let's go to this command and instead of embedding install Let's type NPM in it like so and now with
selection.
This prompt this utility will walk through creation of the package the gist on file and afterwards we
see prompt to name our application or a package.
And here is the full name up but afterwards this script actually terminated and the reason for that
is that we cannot connect it to the end of this process and you may guess that we need to add Dash 8
the options in order to be able to proceed with this interactive conversation with no GSM container.
Let me clear a terminal and move to this command back and here let's add that a D.
Options and make sure that you add those options somewhere before.
Name of the node image.
Let's browse Anton and now I am able to proceed with those prompts.
I am happy with this default application name version is 1 0 0 0.
Let's press Enter description is empty.
Again I'll use the default values everywhere and re point in the Jesus death command to get repository
keywords altar license ISC.
And if I am happy with all those settings I could do press enter and file baggage.
The Jason the file should not be created in our local folder Let's verify it allows.
And yes I see actually two files package the Jason and package look.
The Jason.
I will not explain in details what this package looked the Jason File means but if I'll go to resorts
to the gold and the gold to our Express application you'll see those files here as well.
And if I'll have a look at the package the Jason the file you'll see this set off.
Actually values assigned to some keys like name whereas some description and so on.
Great.
Now we are ready to try again.
Installation of back just using npm install command but important outcome from this command is that
the node just container has actually created files package and the Jason the file and this one inside
of our local folder on our computer.
And now those files actually belong to our application and you are able to run this application using
any ours or not just container.
All right let's not go to terminal and let's run and being install a command.
But actually we need to run in being this document along with name of the package we want to install
into our project and name of the package use Express.
Here it is.
Let's go to terminal end here.
Let's clear it quickly and let's run command npm install express like so here was and type comment that
will be executed off the start of this container.
And please note that each time when we run such command we actually start brand new container let's
both Antigua and now you see that the summer job is undergoing right now and you'll see now that express
package was installed into our project.
And now if I would go to visual studio called you should see here.
Let's refresh.
You should see here.
Note modules folder inside of the Express folder and inside of that folder you'll see by each of our
folders that contain actually additional packages that were installed along with Express package.
That's because express package itself has by each of its own dependencies.
And here you see that in total fifty packages from 37 contributors were added.
Great.
That's how we were able finally install express package into our not just application.
And notice that for that we have used no GSK container and we have executed some NPM commands inside
of that container.
It is very very important.
We have not used node or NPM locally on our computer because the simply absent the moment great let's
not wait to start our application once again using Node in the GSK comment.
Let's clear terminal and go back to this command and instead of NPM install express let's type node
index.
Here was our intelligence file.
Here it is.
And we want to execute it using Node less porous Antrim and we see that we have connected actually to
node Jesus brought us inside of the container and container now is up and run.
Let's open up new tap and here let's verify that Docker appears and you'll see that this container is
up and now we're actually able to verify whether we're able to connect to our Express Sara or not.
And you may guess that we will be able to connect to the sport and I am sure that you know the answer.
We cannot actually mapped external port to this internal port three thousand but let's anyway try it
to open up web browser and here let's type local Horst column three thousand like so.
And of course I see this error.
This site can be reached let's not modify our command here and let's at also port.
Let's go to the step.
Let's terminate our application and you'll see that actually this doesn't work with this process because
we're connected directly to node G.S. process that at the moment doesn't actually handle seek in signal.
Let's go to the step and let's stop this container manually using Docker stop.
Command and let's type here.
A seven for example.
Actually we need to use a docker killed better because we will need to wait 10 seconds because again
six term signal is also not recognised by Noel just brought us.
And finally in 10 seconds this container will stop and defy will go by here you'll see that this process
is over.
Let's no at also port Megan.
And here for that let's use option that beam and let's say that we want to simply run this.
No just express application using same boat as was opened by express application itself it is three
thousand.
Let's go here and type three thousand as external port and optical Let's type through a thousand as
internal port as well let's not press enter and see whether we will be able to connect to our expressway
etcetera.
Now let's go to Google Chrome and here let's refresh page.
And now I see my message.
This Express up was executed by no gas container inside of the door.
And that means that now our report made big rocks and now our tiny express application works as well.
And again for that we are required to enter some NPM commands in order to install express package inside
of our Express application.
And if l go to package the Jason File you'll see additional dependency that was added here.
This file and this express package.
Great.
Now let me demonstrate to how we're able to handle control seem inside of the node GSR application and
let's adjust our application a bit.
But let's do it after the small bowls.
See you next.
Bye bye.