Docker and Docker Compose - Project Deployment From Scratch | Oleksandr Kocherhin | Skillshare
Search

Playback Speed


  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Docker and Docker Compose - Project Deployment From Scratch

teacher avatar Oleksandr Kocherhin

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

    • 1.

      Introduction

      1:17

    • 2.

      Why do you need docker?

      6:37

    • 3.

      Planning our application

      8:40

    • 4.

      Installing tools

      3:33

    • 5.

      Creating docker file

      10:35

    • 6.

      Creating api application

      6:58

    • 7.

      Preparing api docker image

      8:48

    • 8.

      Starting api server

      6:28

    • 9.

      Docker hub

      7:01

    • 10.

      Environment variables

      9:29

    • 11.

      Adding database

      17:35

    • 12.

      Making database requests

      11:48

    • 13.

      Volumes

      19:15

    • 14.

      Auth service

      12:30

    • 15.

      Frontend service

      11:43

    • 16.

      Running frontend in production

      11:51

    • 17.

      Docker exec

      4:56

    • 18.

      Setting up nginx

      16:17

    • 19.

      Proxying api requests

      14:53

    • 20.

      Docker network

      11:58

    • 21.

      Frontend proxy

      15:12

    • 22.

      Last tuning

      14:30

    • 23.

      Do it yourself. Mailer

      2:42

    • 24.

      Pushing to git

      6:05

    • 25.

      Setting up production server

      8:14

    • 26.

      Deploying project

      10:13

    • 27.

      Cleaning docker

      3:38

    • 28.

      Homework

      1:45

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

527

Students

1

Projects

About This Class

In this course we will build an example of real application using Docker and Docker Compose. This course is fully focused on fast and deep dive into creation of real application with Docker and Docker Compose. We will start from scratch and step by step you will get close to finished real application which is suitable for local development and easy deployment. You will deeply understand how to structure your application, build configuration files for Docker and split configuration files. We will write code together in efficient way to make it pure and avoid complexity. 

For each lesson you'll get source code of the lesson, so it's easy to see the progress and get a working app on any lesson you want. 

By the end of this course you'll be able to:

  • Develop and deploy projects with Docker and Docker Compose
  • Build real applications with Docker from scratch
  • Learn Docker through real usage

What you will learn in this course:

  • Structure and configure configuration files and projects

  • Split project in services

  • Understand images/volumes/networks/containers

  • Implementing development and production environment

  • Configure own server and deploy application there (You will need to pay for a server for deployment or just follow along)

Who is this course for:

  • This course is for you if you want to develop and deploy real project from beginning to the end with Docker
  • This course is for everyone who is interested in learning Docker deployment on real project
  • This course is for you if you want to improve you knowledge of Docker and Docker Compose

What skills do you need:

  • A computer on which you can install software (Windows, MacOS, or Linux)
  • Basic linux skills is a plus (not mandatory)
  • For deployment part you'll need real linux server for which you normally need to pay (not mandatory. you can just follow along)

If you are feeling like you learned Docker but you still still missing knowledge of how to build your own real application this course is what you need. This course is fully focused on solving real problems with deployment and development the application without just learning dry Docker possibilities!

Meet Your Teacher

I am a full-stack developer with a passion for learning and teaching what I know. I have been programming for around 10 years and teaching for almost 6 years.

I believe in learning through doing and this philosophy is present in every course that I teach. I love exploring new web & mobile technologies and my courses focus on giving you the edge in our fast-moving industry.

See full profile

Level: All Levels

Class Ratings

Expectations Met?
    Exceeded!
  • 0%
  • Yes
  • 0%
  • Somewhat
  • 0%
  • Not really
  • 0%

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. Introduction: Welcome to my course about dark and docker-compose. It's so great to have you here. In this course, you will learn how to create real project from scratch. You won't just learn some features of drug or official documentation. You will see on the real example which consists of five microservices, how we can improve our local development and deployment. We will start with the empty folder and finish with the real application which will be running in our production server. There are no theoretical things inside. You will learn unless staff that you really need in order to use Docker and Docker Compose for your own applications such as containers, images, volumes, networks, and much, much more. By the end of this course, you will for sure be able to create your own applications of any complexity using docker and docker compose. Who am I? My name is Alexander cohesion and I'm a web developer, was more than ten years of experience, as well as a professional instructor with various courses regarding web technologies. I did my best to put all my knowledge inside this course and I want to share it with you. So welcome on board and let's get started. 2. Why do you need docker?: in thesis media. I want to clarify why Darwinian darker. So basically the first question is what is DACA If you goto official website. I couldn't calm. There is a link y docker and here you can read something about developing with DACA. So basically, the main idea is that we're developing a lot of EPS today and it's different frameworks, different languages, different architectures and different tools, and it all increases complexity. And this is exactly the problem that talker is trying to solve. Let's just imagine a simple use case. For example, you're making some no GIS application. So it's just a website and you haven't bacon. No cheers was, for example, express. Then you have some data base, for example mongo db, and you have some front and let's say react. And basically, maybe this is the small project. So this are three main things that you need database back end and front end. And the point is that at some point, you want toe open your cold in other machine, what problem will you have? The first problem is to remember all technologies that you used, for example, use some version off node, and maybe you developed your project like a year ago or two years ago and did it update it with the recent note? And then you just use this project on your machine. You install the latest node and then nothing is working because basically, something's in. No chairs were changed, which is fine, but basically we didn't look any version inside our project. And maybe we even don't remember what node version will head there. And the same goes with every tool that you used. For example, it can be database and then you installed in Cuba database, and then you need to make rate your data somehow because the version is different and this does not give you stability off developing. I think if you're looking the Syrians, you already have some experience and some problem in skills, which means you may be worked in some team and company, and basically, normally when you come to some company, you need to set up your machine. And I would say from my experience in almost all cos it's really tough process, like you need to set up a lot of programs on your machine, sometimes with specific where Shen's maybe there is a company. Documentation like how to install everything, but it is outdated. And then something is broken and you need to fix it and ask like different people in the new company to set up it properly. And it can take like, 23 days. And I had this experience and they saw other people struggling. And then this process continues again and again for each new person in a company, and doctor solves exactly this problem. So basically you are sure that you're cold is working exactly the same on there. Any machine, it's not on the works on my machine, and then another person can started. This is like easy on board in four different developers, easy supporting, and you're sure that your project will work. I talked only about development, but what about deployment? Let's say that we want to move our cold toe the server so it will be accessible in Internet for everybody. And this is like standard process. We're doing it with every project, and basically there are always problems there, like you want to deploy your known Jess application. You just run to server. You need to install no there with specific version And what will you do when you have several different projects there with different node versions or with different dependencies? And then you has installed uber in newer tools and then maybe all tools you don't need anymore because some project is obsolete. And then you just have a mess with different libraries, different versions. And this is all uncontrollable. Hell, maybe you remember how people were deploying projects previously, for example, with FTP Klein's like vile zilla, they were Korpi in just files off the project directly to the server. Then, of course, people understood it's not scalable. Different people can deploy things simultaneously and so on. And there. Come on you tools like, for example, instable or puppet, where you just contrite recites what you need to do to deploy your application. Yes, of course, it's easier with such tools, but it doesn't solve the problem. Want to have a stable cold, which will be exactly the same everywhere where we can start our code with one command for development locally, and we can deploy it in any amount off servers with simply one command and manage it easily ? I can't, of course, say that doctor is a silver bullet. Of course it's not, but it tackles and solves lots of problems for small, medium and huge projects. And a lot of companies all over the world are using docker successfully and it's really not . Small. Project is really stable solution which were used lots of years already. Dr. Nowadays is a huge ecosystem with different products, paid services, free services, different tools and so on. And when I started learning, Docker for me was the question. Does DACA solve my problems? It was not like DACA is new cool thing go. They want to test it. I really wanted to solve my problems and my problem waas that I want a consistent development and production environment where it will work on any machine in the same way and I won't struggle and this is exactly what I want to cover in this course. It's not about learning Dhaka from start to the end and learning the all tools that exists about Docker. It's just to solve the problem off consistence development locally and deploy in the project to production with the same steak, easy and without problems. If you have any comments or questions, feel free to ask me and I will answer them for sure 3. Planning our application: in this video. I want to talk about Dr Tools that we will use in our application and to talk about structure off the whole application. So, first, let's talk about tools. The only additional tools that we will use except off the doctor itself is docker compose. We won't use any other tools in discourse at whole document itself is really low level toe , so if we use talk her directly, we need to write a lot of different commands. Into the console was different attribute, which sometimes it's hard to remember, and we want to use Docker compose as a simple of rapper for DACA of which manages, in an easy way, our containers. So basically, with Docker compose, we can describe how all our containers will be built and how they will behave in different environments. If you know something about DACA. Maybe the question now is. What about docking machine or Dockers? Warm or cool? Burnett is, and so on. Will I talk about this? Technology is in the course, and then my answer is no. We will take it crisp and small with stock a compose and this is a really nice tool, and you just need this'll. One tool except of Dhaka itself, of course, to deploy the applications off small and medium size from my point of few, 90% off the Internet can exist with projects on single Sarah with, for example, single database and with started with docker compose, we can easily manage, eat and deploy our projects and develop them locally. And then later, if you need, you can invest your time and money in scalable solutions for a lot of service like, for example, Cooper natives and improve it there. But normally then you're in another 10% off Internet, and this course is not enough for you. Now let's talk about our project. Basically, it's not some project that they just thought about that doesn't exist. This is the rial project that I developed not so long ago, so it is 100% riel and it works really nice in production without any problems. By using Chazz, DACA and Docker compose. I like this example because it shows the possibilities with Docker compose and is really suitable to most projects that people can develop, which means after finishing discourse, you can use everything that we implemented to create your own project. So what do we have here? We have a front and part off our application, which we will be doing in react. Basically, we won't. Right Any rial direct code, like creating the whole application or something like that? Our idea is that in front, and we just have a direct application that can be started. So basically, this front and part is our first service and why we're talking about services service means something isolated, which means we can just take this one service, for example, front and and develop eat on its own if we want why service is a good because each service is completely scoped and it can use different technologies inside different frameworks and so on. For example, you can say, OK, my first service with a pie is using known chairs, and my second service with the guy is using ruby, for example, and they are completely isolated and they simply work in your applications simultaneously together. Okay, so our first services front and where we will get data. Basically, we need some epi. I which ruble excess in our front. And so I split it our a pie in two different services. One a pie is related to user payments and every all stuff which is related to users. So this is something like authentication FBI. So it's only related to users Off course we need to store somewhere all data from our A p I . So we need a database for our South service. I will sleep. I service. So basically we need in your service, which will be a database service. So we will have inside Mongo DB database for our authentication service. As I already said, we have another day. This empire is less important. This is related to all entities that we have in our application. So basically, for example, pose off the users or comments or categories, or I don't know that three off the categories and so on. So basically not that important stuff. So basically, this is exactly the point why I split it into different services, because when I am working with that, a base off users of payments, I need to be like super focused. I don't I just can't make an ever there. But when I'm working with database off, some not that important stuff, like updating the category And just when one category in the website is broken, it's not a big deal. But when the payment off the customer is lost, it's like the tragedy. Okay, so just to be clear for now, I talked about front and service our syndication service, authentication database service ap I service and out the FBI database service. So we have for now, five services. Now, one more service and this is Mailer service. Basically, for me, this is the service that we need in every application. But maybe if you don't have Malin or authentication, you don't need it. Basically, all the stuff which is related to Malin users is doing there. So basically, if the user is registered and he gets an email or he forgot the passport, he gets an email. This is what this service is doing. So basically, if you have any male identification, I moved it to additional service. And now one more service. And without this service, we can't leave for sure, and this is n jinx service. Basically, if you don't know what is in jinx, this is really handy tool, which is actually a lot balancer and have observer and the proxy and actually whatever you want. So in every project you want toe configure where, for example, your requests to go in when they're coming to your host? Let's say your hostess food bar dot com. So basically, if your quest is full bar that come you wanted to go to your front end. But if it is slash AP I a Dent and I don't know Post, then you want toe goto our pay and so on. So basically, this service will configure the engine ICS inside and will resolve all holes and all droughts off our application. So this is it. These are all services that we will implement in this cars. But maybe if your project is smaller, you can leave just with front end and then beckoned with your sky and additionally database , which means you need it least three services and, of course, n jinx. Which brings us to four. So this is the lowest amount off services that I see possible for normal application with front and beckoned. If you kept, for example, on the beckoned trend rain, let's say you have like ruby on rails and simply templates in Beck, and then you don't need, of course, front end. And this is just one service for beckoned, one for database and one for in jinx. If you have any comments or questions, feel free to ask them, and I will answer them for sure. 4. Installing tools: in this video. I want to talk about tools that we need to install in order to start developing of ways darker. And the most important tool for us is dark. A desk hope so. Basically, this is the dark installation which has everything inside that we need. So basically, here in official docker website, you can go to product and here is dark A desktop. You just click on the link and here you condone lauded Former Quest, for example, or for Windows. So just installed this application. And after installation, you have something like this in your a bar when he started. Like DACA desktop is running so basically just started and it hangs here in the bar and this means that we can develop our applications with talk. So I already have DACA desktop installed and let's check if we have ability to work with it . So basically, I'm here in the console and if I will dry dock minus minus version, for example, it should give me a dark aversion. This thing is available through this dog a desktop. Now if we're writing for example, doctor help, then we will see a lot of commands which are possible to use because here the doctor was already installed. Now regarding other tools. Basically, when you in style docker for desktop, you get dark hair and docker compose. So basically, here I can dry docker compose minus minus fashion, and they also get their output. That docker compose is installed, and basically the idea of a darker and darker compose is that you don't need to install anything. Additionally like, let's say we're right in our a pie with no jazz. This doesn't mean that we need to install it on our machine. We want to install it through docker inside containers. This means our machine will always be clean and won't have unnecessary installations. But in scope of this course, I recommend you to install known jazz on young own machine from official website. You don't need to do it when you know Darkened aka composed lately. But in this course, I want to show you this migration off your local development inside the Dhaka, and it will be easier to show you if Bushehr note and in PM available in your console. As you can see, I already have note Russian Soutine actually doesn't matter that much. At least you need to have something better than 10. Basically, on the official website, you simply need to download here your package for node, for example, For 12 or for 13. It doesn't actually matter that much. So when you install it in your console node minus version should give you with an old version. If you get this output, this means now than your machine is installed correctly and you're ready to go. So if you successfully installed a doctor and note on your machine, then you're ready to start this course and you don't need any other things to be installed . If you have any comments or questions, feel free to ask them, and I will answer them for sure. 5. Creating docker file: in this video, we will start with creating our docker file and Docker compose basically here. I didn't even create the folder for our projects. So we're starting with complete scratch. So I think we can name our Project Riel World with some doctor words. So let's say it's riel world. Dr. So in this case, we understand that this is a really a world example where we're write code for the project with DACA. So here I want to start the editor and we don't have any files yet. So the first file that I want to create is talk here composed dot jahmal. So this is the file where we will write our docker compose configuration. I already talked a little bit about what Docker compose it, but let's check in Google. So basically we're just right in Docker compose and jump inside official website to the compose. And basically here is the idea off the composed. So this is a tool where we define joining docker containers, which means we create a jahmal file and this is the describing off how our application services will work. How will start and stop containers what configurations and environments are contained containers need for different environments, for example, for local development off a production and so on. So, basically, from my point of few, Docker is low level tool where you need to write a lot. But this is super flexible and Docker compose is a nice high level rapper where you simply declare it'd. Lee described what you want to achieve and Docker compose is due in thesis with DACA. So let's start to write in our Docker compose the first thing that we need to say Here is a version and basically as Dr Composer was evolving, it version changes. This means docker compose syntax and properties are different in different versions and now we have Russian three, which is the U. S. And we will just specified here. So Doctor knows what version were using. And the next thing that we need to describe here is services and basically the services that we will right here are exactly services that we discussed when we planned our application. So basically we need here to have front and service and then FBI and EPA database and so on . We will start with one service just to check how it works at all. So this will be service for our Ikea. And just to remind you, our FBI is a service where we have not user specific data. So, for example, categories pose and all this stuff we have inside our a pie So the next thing that we want to specify here years, what folder were born to reach Dhaka file and now the questions are versatile is what is DACA file. So basically, here you can see the structure off our project we have here Rail World occur and just one file We will create several folders basically here. We want to specify. Okay, we have here front and and we have here any pie folder and we have here hours, folder and so on and so on. So basically each service will be a folder and later we will discuss how to move this folders. Two additional depositories. So we have like, for example, for front and just a single rep. Oh, and we can just develop with this one rapper. But for now, we will put all folders for all services inside this one project. And basically, the idea is that docker compose reads the talking files from each folder like from each service. And we will check what is doctor file in a second. So let's jump to Google and right doctor file. So basically, as you can see, the documentation of Dhaka is really nice and you almost always a jump in tow. This documentation on as the first link when you write something in relation to Dhaka. So basically here is doctor file reference and what is DACA file? Dr. File is a text document which contains all the commands off the user which will be triggered when we create an image. So now the question is what is image? Let's say you install Lennox on some server or just in your local machine and you use an image for these. So basically the image is something like a snapshot how your installation will look like and this is exactly the case. Let's say that we just have an image. So basically that pretty find installation where we have inside like Lennox, like basic distributive with for example, now installed and when we used this image to create and you distributive to install it, basically we will get out of the box, not just draw Lennox. But also note, for example. But it can be a little bit complicated at the beginning, but you will see it in a second. So let's jump inside FBI, for example, and create in your document, which is called DACA file with big the letter. So basically, as they said, we have now Docker compose. This is like composition off everything. So this is the high level thing that manages everything and in a pie, the docker file. So basically, we will have DACA file in every folder, like in every service and in Dhaka file which specify how, exactly with this service should be prepared. And the first thing here to say is from so basically from means of what image we want to take, we can say here that we want node image and here we can specify the version. For example, no 13. Then it means that we will create in this taco file than your image with No. 13. This means that this image doesn't do anything with just prettified. Okay, for our FBI, we need an image where node version 13 is already install. This is it. We don't specify anything else and leads jump back inside our docker compose So basically here inside our ik I would want to specify of what folder? That this FBI is related. So basically here we can say build And this is the special property where we're saying what fall this should be used So basically here were saying just dot slash ap I So this is the folder where Docker compose will be looking for our docker file and this is exactly what we specified. Let's not do anything else and try to try to docker, compose, build and enter. And as you can see here we have the message built in a sky which means docker compose sees our A p I service that we defined and now you can see that this is step one off one and we have this line from No. 13 that was certified in Dhaka files, which means DACA composed sees our in from No. 13 and understands how he needs to install the image for thes e chi and basically can see here. Pulling from library node and pulling is coming here, which means we're downloading from Internet. The image for No. 13 basically now in our machine. We have downloaded image for No. Two team And let's check. I will just start it once again. And as you can see, it was like super fast because we already downloaded this image and we have eat on our local machine. This is why we don't need toe. Don't lord it once again and DACA understands it and just build what we said so basically just took this from North 13 which is available locally. And this is it the last line here Successful Tag it, Real docker A real world doctor ai latest. Basically, this is the key point. What we did hear from the image note 13 we created in your image and this image Israel World Doctor A pie latest. So basically the idea is that we take some base image, for example image with node and then we create our own image for our project. In this case, we can do more things than just taken the North 13 because basically, if we don't need anything else, we can just take this image directly and not create our own image. But here is the idea that we will do more things here which means for our service. We always create in your image. And if this image is based on some basic image, as you can see, you should not use Docker commands directly when you use docker compose. So basically here you didn't So how dark image should be pulled, how it should be build and so on because Docker compose is doing everything for us and this is really stable solution and we just define how we worked it toe work. So as you can see with Chester four lines here and one line inside our docker file was successful created in your image which we will use later for our a pie. If you have any comments or questions, feel free to ask them and I will answer them for sure. 6. Creating api application: in thes media. I want to create our known application for a pie service. Off course. We won't create the whole application from scratch. We will just great to route so we can test that our empire application is working because this curse is full focus on the darker and not about creating and known Js application. So for these, first of all, we need to jump inside our FBI folder. So here I am, inside a pie, and they don't have anything else except off the doctor file. So basically here I've want to write in PM you need and hit. Enter. And this is a tool to create a package, Jason. So, as you can see, this utility will create our Peca. Jason, we can just hit Enter. It doesn't matter what we have here, and our picket Jason will be created. So as you can see now, we have packet Jason, and we can check how it looks like in the editor. So, basically, this is just simple Picket Jason. And now we can add some packages I want to install here express. And if you don't know what expresses this is the most popular framework for known chairs to create applications. So basically was simply arrived in PM in style express. And here it is. Our express will be installed locally so you can check here inside package Jason that we have now expressed as a dependency. It's also important to see that we have now node models and package lock file package Lakis . Fine. This is the lock file for our packages, but no models we want to ignore. So basically, as we have known models in different folders, we can ignore it directly, intrude off our project. So basically, we want to create here, get ignore file and inside, add old models to get ignore. And you can ask, Why do we need to do this? Because basically, at the moment when you want to commit it toe get rep. Oh, you don't want to commit any packages because our packages are defined in package Jason and package log. And in any machine, we can install correct packages just by exciting NPM install. Now, let's create a source folder here inside our FBI. So we have just note models here and we need a source folder verbal, right, our cold off repay. So basically here I want to create in you file index dot Js and inside eat create express which we will import with require from express and this basically it. And now we need to create a new instance off express. Now, from express package, we can create our app So basically ab equals express and we just need to call it now we can use this app to define our jolts. So basically we can say app get and here will be, for example slash Hello And here we will have a function with request and response and inside with this function will want to return something I think for testing purposes we can name it's less test So we know that this is the Ural toe test if our services working And now we need here toe say arrest sand And here, for example some strength Our heat I server is working correctly So basically just if you don't know what expresses Basically we creating, um from express and now we can register our routes for known chess. We register here route test and this ato perimeters request and response. These are perimeters inside which we get some properties from our request and then with rests and we can send some text back and check that it is working. So basically now, when our observable be started and we will jump to slash test our stream will be rendered. Now, after registered Harold, we can start listening on our service. So let's say here app listen And here we need to specify a port on which will be listening . And here goes cultic. So basically, Colback means that our EP listen started successfully. So here is starting or started ap I service. This is it. Basically, this is the most basic node server that we can make. And let's start it now for these in our package. Jason, we need to specify as script. So let's name our script start and this is the special name in that they used to start a production server. So basically everywhere where you see words start, this means that this is for production. And if you see word death like in Pam Ron death, then it will before development. So here for now we're human, that we're making production of Web Serra, and here we start with simply makes annulled and then source index chess. So we just start our Terram. Let's check if it's working. We're here inside our FBI and we just need to write and PM John and here will be start. As you can see, we get a message started a pie service, which means our server is working. We can jump in browser and in browser as you can see where getting cannot get slash because we didn't register slash your l But when we ride slash test would get a message Our FBI server is working correctly. So this means that our code is working and we can start with developing our of observer in Dhaka. And this is exactly the point why I wanted to install note and in PM on your machine because now we tested without darker that our application in is working and now we will start to pack it inside darker. If you have any comments or questions, feel free to ask them and I will answer them for sure 7. Preparing api docker image: in thesis video, we will fully prepare our a pie DACA image. As you remember in previous video here we have a doctor pile ways from No. 13 and this command means that at the moment when we build it our image for a tie No two teen was downloaded. This image is now in our computer. So the reason Nice command from dark hair which can show all images that I don't loaded on your machine. So basically, in console you can dried docket images and then you get a huge least and for you it shouldn't be as huge as for me. But basically here I will scroll it a little bit. You can show in the top that there is a table with repository tag image 80 created and size and basically here. The reason my least off all images in my machine off course is quite a lot. But here you can see note with take 13 And here is image 80 and when it was created, so basically for you it should be something similar. I have different known versions here, as you can see, but basically the idea is that this image is there you can see eat and you can work with it if you need. So basically, if you see these on your machine and the size, this means this This image is available and you don't need to pull it every time. But it is there and you can just build any project with this specific question. Now let's continue to prepare our node image. So basically we know that now we don't loaded No. 13 and we can specify they have working director here and basically what does it mean? So when we have this line, we have simply air Lennox image with installed note so you can imagine threes like a standard Lee nukes director is there and we can right here, work dear And then, for example, user sores app. So basically, this means that this will be our working directory where our application will live. Basically, it can be any directory. It can be just full. It can be slash, but I prefer toe have director like this. This is just fine to have any name because you don't have same things inside one image. So basically here inside our image is living on Lee One project which means it doesn't really matter what this working directory will be, but we need to specify at least one. The next thing that we want to specify. Here he's toe Korpi the package Jason and package lock file. So, basically, as you can see here, we have packet, Jason file and package log Jason, and they dare Is that this files? As you can see them now on our local machine, these are local files that we are changing. End that we will continue to change. But now we have an image. And when we build this image, we want to copy inside Beckett, Jason and Package Lock. And you can ask why? Because inside our image will want to install. Note more deals. Basically, For now, we installed node models in our machine. But of course it's not correct. It's only for testing purposes. The idea is that on your machine, you don't have any note models basically on your machine. You just have a sores, which you can modify, and then all the other stuff is living inside Dhaka. So let's try it, and you will see the idea. So basically here, we need to specify that we want to copy Beckett, Jason, file and lock. So we can right here. Copy and then package and then star dot Jason and here dot Slash What does it mean? We check here all files in the route with the name package and then something dot Jason. So basically, it's package log and picket Jason. And basically, it will be always like this. Sold. This is safe. And here we say dot slash, Which means please copy them tothis working directory. Because with this command were saying that we are now inside this working directory. So this command will corporatists two files when we're building the image inside our image . The next step Eastern style. All our packages. So for these, we have special command Iran. And then we seem pleasure, right? What? We're right in normally to the shell. So it will be in PM install. So? So this command will install all packages inside our image in user source app. Now, after the's, the only thing that we need to do is to copy all other files. So this is why we simply can say copy dot dot What does it mean? Dot means please take everything what you see here and dot means that we're copying here in thes directory. So basically, you can ask why just we didn't write this dot dot here where we have Beckett, Jason and then just didn't write npm install. And the answer is that we don't want to copy inside note models, and basically, this command will just simply could be everything. So to avoid thes, we need to create new file here dot DACA ignore. And inside, As you can see, I created dot DACA ignore. And we can simply right here node models. And it works in the same way. Like get ignore file. So basically, it is just a file for darker and darker understands that we don't want to copy node models inside if we have it. So basically, once again, this is exactly everything that would roll. So five lines and our Dr file is ready. So once again, we took the image. Was No. 13 were saying that working directory is user source app recorded two files there and run in pm in style. And this installs all note memorials. Then we could be everything inside except off our node models. Our Dr file is ready. And now let's check once again what we have in Dhaka. Calm polls. As you can see here, we don't have almost anything here. We simply say okay, please build a pie for us And there is a Dr file inside and this doctor file will be used. So let's jump to the console and right Once again Docker compose build like we did previously. And as you can see, it looks differently. So we have here building FBI the first step from No. 13 like we had previously. It is really fast now because it is locally. Then we're in working directory And here we're copying files and we're right running here NPM install. So basically, here we have a warning but it doesn't matter because we don't have description and repository field. Then edit 30 packages from contributors blah, blah, blah Which means packages were successfully installed. Now we have a copy and now our container waas successfully built. So basically we now have an image and we can drive here docker images And as you can see, somewhere here he's our image with the name Real world Docker a pie latest Is it consumed the top. We have Repository, riel World, the Doctor, a pay and tag latest and this is the image E. D. And it was just created. And the size of this image is 900 megabytes. Which means it's not that small size to create an image of what is known chess. And we will fix this in the next lecture. And for now we just created the image for our a P. I were installed everything inside, and our image basically is ready to be started. 8. Starting api server: In previous video, we created our docker file for a pie and it was successfully built. Now it's time to start of observer that we created basically in Dhaka file, you can specify toe additional things. This is exposed for example 300 command and commanders in the ray, for example node and then coma. And here Waas, I think Ron Ah, start. So the idea is that exposed is exposing the part So this means that we're using poor 300 inside our doctor. So here, inside, sores with specified that this is the Pore 300. But this port is inside our docker container and we want to expose this port for outside world, which means if we don't expose the sport, we can't get our web application with which is raining inside their container. So to do this we can only expose the port. The next command is command, and basically this is what started our observer. So node Ron Start will simply start the observer when we want to run our country our image . So basically, the idea is that we don't need this command here, so basically we will remove them and the question is Why? Because we want to configure everything like boards exposing and what environment it is and what commands to be using inside Docker compose because this is more flexible. And this is our only source of truth. Yes, we have configurations for for example, FBI inside Dhaka file. But this is the configuration. How project ap I should work, but not how we should run it from outside. Now let's jump to our Docker compose Yom and he has specified two things. First of all, it will be command. This is what you saw in Dhaka file here we can ride in PM Ron, start. This is exactly the command that we created to start our web server. The next thing that we will write E sports And here we will write boards 303,000. Sorry, he closed Resultant. And let's check, I think with command it is clear. So basically with this command our container will be started. But ports is not clear Why? It is looking like this. First off, all I wrote it not correctly. It should be written like this. So here we have a dash and then the string. So basically what does this trend mean? So here. I want to spaces, of course. And the stream means that the port on the left is the host port and host means our machine and port on the right means container port once again. What does it mean when we have here a P I source index and here with specified 300. This is container Port, because the web application is running inside container with this port. And then we want to expose the sport as 3000 port. So here we can drive five or 6000. And this means that in a port will be 3000. This is the sport, but port outside will be 6000. So basically, if we will right here some other number like other port, it just won't work. Because here at the port 1111 does not exist inside container and no application is listening inside for port 1111 Basically, with this command. When observer inside container is started, then our observer is listening on poor 3000 and we're basically finished here. We just need to specify what command will be run when we start our container And what pours should we expose inside this container? Now let's tried Once again Docker compose built And as you can see, everything is starting again because we changed docker file. But now let's try again. And as you can see, it was exactly much faster because we didn't make any changes to drug a compose file to doc File. Sorry, This is why it was almost instant. So now Docker compose build created our image and now we can use this image to do this, we need to try Docker compose up. And as you can see here we have several messages first of for creating network. We will talk about networks later. For now, it doesn't matter. Here, you can see creating real world docker FBI. This is exactly container with this image that we created and it was done. And here we were Attash into this container. And Thies is the logs from these container, which means here a p I one you can see this is our a pie container. And here the locks No source index, This is our command to start any pay. Now let's switch to our browser and reload the page and As you can see, everything is working as it worked previously. But as you can see now, we just have Dr Compose up. If I will stop it with controlled, say or common, you can see that it stopped working, which means this is exactly these. So when we ride Docker, compose up It started out a by service and you can see it here then inside our browser, we have local host 3000 and test. If you have any comments or questions, feel free to ask them and I will answer them for sure. 9. Docker hub: in thes video. I want to talk about such things as DACA Hub. So basically, here inside our docker file rolled from No. 13 and then door came magically Don't lauded this'll image from somewhere and we don't know from where exactly So basically this from where Waas hub dr dot com So this is basically something like node Js registry, for example. So basically, it's a place where you can push and pull images, which means this is like a storage for images. And let's say we're looking for note so basically went right node in search, you can see here containers and here they are sorted by popularity so you can see 10 millions plus, which means this is the most popular rep. Oh, and you can see this is the note image. This is no Js the JavaScript based blood from for service side and networking and we can click on it and basically one more important thing, this is the barge here official image. This badge means that this is official and like you don't Lord the thing which is really normal like no hidden things inside. So basically, this is Dr Official image for node and you can see here supported tags. And this is really one important and interested in you. Basically, this means that you can take any tag off node. And for example, we took no. 13 so basically we took something from here. But basically the point is that with such notation, would don't even know what exactly. And at the bottom somewhere, you can see quick references And what is no jazz, how to use this image and so on. So this is basically eat, but you need to do normally is just to find what image do you need for example, through surge And then here right from and then the tag. So basically text you can see here when you click on tags the rod different images and you can see the size off the images like off course in no lots of them, because this is like super popular image. But of course, when you are looking something not that popular, you can see maybe several texts and just one image, one type of image. Because here you consider this is a slim image, which is smaller and thistles, the bigger image and so on. But there is one type of image that I really like and it is called Alpine. So, basically, if Google Alpine image and open Wikipedia here, you can see what is this at all? Okay, not Wikipedia, but Dr L. Pain. And the idea is that Doc images are too big and usually we don't need everything. This is why people tried to create smaller images, which means, for example, as you saw here in console, whenever right to doctor images and find our node image here it is quite big. It is almost one gigabyte, and basically we didn't install anything there. So this is like raw image and Justin's told Know that so if you have a small server, for example, for $5 rented somewhere, normally it will have, like, maybe 20 gigabytes off storage. And this means that you can't install that many images there because you will be soon out of space. This is why Thistle Pine Lennox was created. So basically, this is a special distraught and you have super small docket images and the smallest images starting on Lewis five megabytes. So basically, this is really, really small, and you can see here that I have note little pine, for example. Eight. This is like all the version, but this is really small. As you can see, it's only 67 megabytes, so basically we can switch one gigabyte to something around at least 100 megabytes. Basically, in old popular images, you always have an Alpine vision, and here to use an alpine with simply can dried dash and alpine. But I want to be better than this because I want always to specify strict Russian. For me, 13 can be different. So this is why we can check here. What is the latest fashion? For example? 13 12 0 and I want to write it. Least the teen 12 0 and then dash Alpine. As you can see here when I try toe search 13 12 0 Alpine. You can see that it is existing so we can use it. So basically we're using dis notation. The 10 12 0 Alpine this will in style for us was the next building off our image. Alpine version. So let's do this now. I just tried docker compose build and you can see that we will be done lord in your image. But this image will be much, much smaller. You can see that it is really fast. So here are images building again. And now, with talking images, let's check. What does it take? So here we have knowed 13. It was almost one gigabyte and we have known with alpine and it is only 114 megabytes, which means, like super simple, small and for our needs, it's really sufficient, which means normally for our project. If every image will take something around thes and basically we need maybe four or five different images in total, it will be somewhere around one gigabyte. So just to sum up, what is Dr Hubbert? This is the place where we store images or not. We but where people are stirring images. We don't plan to store our image that we create for the project in Dhaka High hub, because first, it is not free. Okay, it is free for one image, but we want more, and secondly, it doesn't make much sense because we will share our images in another way, which I find quite convenient. If you have any comments or questions, feel free to ask them, and I will answer them for sure. 10. Environment variables: in this video. I want to talk about environment variables. But first off, all I want to specify one important perimeter in our docker compose. And this perimeter is called restart. And here it equals unless stopped. What does it mean? It means that we're saying here the docker compose should restart our container. If it is, for example, stopped for any reason like an error over terror. And the doctor compose will try to start it again and again if we don't stop our container by hands. And basically you can ask me a what other options and how can I get all perimeters that I available in Docker compose? And there is a really nice page dogs DACA dot com. So it's official slash composed slash composed file and this is a reference off composed file Version three and version three is what we have here. And basically it's like super long and normally I just make common death here and I'm looking for example, for what I need. Let's say restart and here you can see that we have property restart and this is restart policy. This is not what we need. But here is restart and you can read about Restart. So no, this is by default. So containers won't be restarted under any circumstances and always means always restarts and on failure. And unless stopped almost in all my applications, I am using unless stopped because this make much sense. So basically, here in thes file on this page, you can check all properties that exists in the composed file and read about them. So basically, this is the source of truth and the highlighter command. If you want to check what some property is doing or what is the correct syntax to look here , for example, we can look in ports and here you can see boards somewhere we can click in the dock. Oh, and this is here. What forced us? It exposes. Pours thesis, strut, Syntex, Host container. We already know it, but here you can read more information about it. Now let's return to our environment variables. Basically, let's assume that our application will grant and in development and in production. So we have only two environments and normally this is what I am using, like 90% of the time. So I don't have staging or something like this. Just development and production. And the question is, how can we distinguish what our applications should do between production and development? So the first question is, why do we need to distinguish something and let's say, first of all, that in development and production, we can run our application in different ports, For example, Then let's say that we're using some third party application like mailing, for example. And of course, you have in mailing something like excess talking, which means they give you a test talking and production talking, which means test talk and you're using in local environment, where you want to test how it's working and production you're using endure pain mining, for example, for sent in emails, which means off course you don't want in development to use production, talking and vice a versa, which means in our application, we want somehow to know in what environment we're starting the application. So basically there are different approaches for this one approach is to have different scripts here, like star for production and death for development, for example, then we don't need to specify anything here in Docker compose because we just wrong different command here, so basically This is the production Docker compose Jahmal Then it is here in PM Ron start If it is development the doctor composed Yama Then it is in PM John Death. This is the most easy approach. But still we want to configure several things from outside for our application, for example, it can be the host or some other properties that we need. So let's assume that we want to have different board given from outside. So basically, here in our FBI, we can ride environment and this is the property for environment variables. And here we can specify board equals 3000. Now let's check how it's working. And here is one nice thingy that I want to show you. Normal live with dry docker, compose, build and after build were run in Docker compose up. We can also right here Docker compose up minus minus build. This means that after before each command docker compose up will try to build an image and if in which is already build it, it doesn't do anything and just make up. This is one command toe save time and to avoid running it wisely. So here we click enter and we have an error and basically, as you can see here, we get a narrow. That composed file is invalid because unsupported conflict option is prettified environment . And this is what I really like about docker compose. You get really nice ever messages and you always know what is it about? So here result environment. Not correctly. It should be environ je or manned. So with n and then let's try again. As you can see now it's working and we started our FBI service. So now we want to check if the Sports Tinggi works. The question is, how do we check it? So basically, as you know in known Jess, we have this and of property from which we can read everything that we need. And normally I prefer to specify you file configuration where I read all configuration but for the simplicity. Let's just try it it here. So let's right here, Consul log and process and and and if should be small and then daughter port and let's right that this is our port. Now we need not only to restart everything part rebuild, and this means that the whole building process it is happening again. We copy files here. And then we start the server. And as you can see, it doesn't take that long. So here, as you can see, port is 303,000. This is exactly what we specified outside. Which means here we can write something like, const board equals, Brought, says and don't port. And basically, then here we are not using 3000 baht port, which means people need to specify port outside. And now our application is stateless. So we don't have anything inside, like configuration boards, whatever. We just specify everything from outside like port, and we can also specify some things like host. For example, I think this is really useful. So we know at what host we start our application, for example, host equals and here http and then we have riel world dot com. So now here we can, for example, read our host and it will be process and host. And here, let's say I really like to write some logs when we start Sarah to know that we have properly configured environment variables so we can right here started a pie service, for example, on port. So here I need other briquettes on board and here will be our port. And then something like our host is And here will be our host. So let's just start this again. As you can see here, we get started it by service on poor 3000 our host is issued Imperial World That come So this is really nice way to configure applications. So this makes our applications stateless and we just configured them outside with Docker compose. If you have any comments or questions, feel free to ask them and I will answer them for sure. 11. Adding database: in thesis video. I want to add that a base for our FBI service basically the first question of what database we will be using and what packages we need in our node application. So it's really popular solution for express and no chest is mongo DB, which is documentary into database. And I hope you know something about it. If you don't, you just goto mongo DB, and you can open the official website and read something about it that this is the most popular database and so on. So basically, I can't say that this is the most popular database. But at least it is the easiest database to start working with databases at all. And there are different solutions how we can use mongo db with note on one off. The most popular solutions and stable is mongoose, which is the Aram for mongo DB, which means away install bongos. And it helped us to connect to Mongo DB. And then here we have different guides. For example, how to define toe define a schema so we can create schemers like for example, we have blawg and this block has this'd this properties and we can just make something like new Model, which is, for example, blogged. And then we were waiting for saving and so on. So this means this is the easy way toe work with mongo db. So, in this course, I will use this one could be rapper called Mangoes, and we need first to install it inside our application. So, basically, let's champ, I am now here in our route off real world, Doc am, I am champion to a pie. And here, NPM install Mongoose. As you can see here, we can simply open Mongo stock. Oh, and here is quick start. And it also says NPM install bongos is sufficient for us. So we successfully installed this package. You can see that this package wasn't styled here in Beckett, Jason, for example. So here we have expressed and Mongoose now and this time to use it. So how are we working with the data basis at all? So basically here which just start our application just like this. But now we can't do such thing because first of all, we want to initialize our connection to database. And when it was successful, Onley then with start listening to our application And you can ask, why is that basically because our application is doing something with database and we have strong relation feels database than application Like it doesn't make much sense to start database after starting the application, because when we're making something on initialize off application with database, it will simply crash. This means that first of all, we want to connect toe database and basically, you can see here this is the example how we can get started. So this is Mongoose. Then we're making Mongoose Connect And then this one goes. Connect basically has DB and we can try to be on debut bonds and so on. If you know that we are connected, I prefer to create a helper which will help me to connect toe the database. So here, inside a tie, sores I create new folder, which is called helpers and inside will be divvied out. Yes, so basically here I want to get Monaco's, which is require Monaco's now he ever want to create our connection. So it will be module experts and here we can dry Daut Connect DB. So this is the special function which will connect to our database and inside were right in Monaco's dot Connect and you can check this in documentation. So here will be some options. We're keeping them for now and we want here to return Monaco's dot connection. As you can see here, we're working directly. Db for us is Monaco's connection. So this is why I wrote it like this. Now, here inside Connect, we have our DB and the question is what is DB? So I prefer inside index Near Index create a folder configuration. So basically, I am doing all my node applications in the same way with the same structure and in configuration index dot chairs. I save all properties that I need for this application. For example, here we can move properties that were road here like board and host. So basically, let's copied from here and inside Configuration index And here we don't want Coast host, but we want model experts Board equals process environment port and the same here Model exports host equals process Environment host. Now we're doing the same thing with DB. So basically here module experts db equals and it will be process and and here should go mongo db Ural. So basically we want to configure from outside off our application this year. L So let's name it, Manco. Um, well, now we should use all these three things in here and in our index chess festival here were warned to have our configuration. Basically, we can destruct sheet directly, and here is require, and it will be We're going out with configuration. And now here we want to get T B. And this is DB that were passing inside Connect. So this is just a simple string mongo, db, blah, blah, blah and level specify it outside in the second. Now I want to change our index chess. So what do we want to do here? Basically first. Awful. We create an app and register some routes. It doesn't matter because we didn't start an application yet. And now we're warned here to get connect toe database. So basically connect DB. This is our special function from require and we're going toe helpers db So, basically, now here we can try to connect DB with round brackets. And as you can see, this is the mongoose connection. And this is this. And when with when you're writing on era, when ever happens we will go here and once means that we're connected. So this means here we're writing dot on and here ero and we want just to make consul log when we have an error and on disconnected This is another object we have connect DB, which means when we lost our connection would want to connect again and vans means that when we're connected So this is open then we start our server and we don't have starts over function yet So let's create it directly here. So basically we can right here start So just on over split things Basically it's not that much cold inside and with just Korpi all of this here. So this is listen and then we have consul log that it was started So this is exactly eat. We can simply also ride this code in here directly once should be with one e But I prefer the function so you can see what's happening. We have here connected be and then on open We have start server now let's check if it's working. Obviously not, but let's see what errors do we have? So we're right in here. Docker compose up build and As you can see, it is building it and then we are starting it. So as you can see here, we have an errors and the you arrive parameter toe open your I must be a strain and got undefined Which means here inside our helpers we give inside db And this DB comes from configuration from process environment and Manco Ural And we didn't specify this perimeter . And this perimeter is not common inside from our docker compose. So basically, here we need first to add this perimeter and then to configure our database. The question is how toe adhere one more service for our database. So, as we said previously here, we need something like a P I database. So basically, the service for our FBI and I think name a p I d be East efficient and inside were born to use mongo db. So basically, if you don't know how to proceed with it, you can simply go to Dhaka hub. So which has jumped in the website. And we're right in Mongo, in the Ural, as you can see the official images and we will take image mongo. So let's click here and here a tags so you can take different tacks. For example, latest, let's take latest, which means here with simply cans, right? Not build like we did here, but directly image so image. And here will be our name. So here was simply need to write mongo latest and this is it. And if you ask me, why not build as you can see here, we don't have a folder for a database, and we don't need toe because we don't have any DACA file which we need to specify for our A pie database. We can, of course, created. But we don't want to do anything with this image. We just need this image and we will use it directly. That's it. This is why I just tried here. Mongo latest. And this is enough. Now, one more thin is that we need to start this service before we start our FBI. Which is obvious because festival, As I said, we're starting database and then we're starting our service, which means if this service will start later than the service, then everything will break. And for this we have special property. Depends on, and here agrees database. So, as you understand, here can goes Lee. So basically like this, you can have like, five database if you have dependence is to fire databases. And basically, database is just a name and our name here is a P I d be. So we're name it to a T i d be. And it doesn't matter if it is a database or just another service. You can specify here Five different services and ride depends on the services. So we're ready now. Our FBI db is starting before we're starting our FBI. So let's try once again, we will get ever for sure, but it's not. The point is you can see here we have exit cold. And as you can see, Docker compose is trying to restart our container again and again indefinitely solid. Stop this and check. What do we have here at the beginning? So here we have errors. And here somewhere, if we don't lauded, is there database? So if you can see here you have requests for a pie database, which means some things regarding our database happened. As you can see here we're old Dhaka compose up build And then here we see creating Dr A. P I d be. Which means Docker compose sees our new service and tries toe create it. So it was successfully created and we are attaching tothis toe services and then error started. So basically, these are some logs and we have the same aero. If I scroll to the bottom, you can see a rose that your eye is not correct. This is the your eyes that were specified as undefined because we didn't pass it from Docker Compose. Now we need to specify this property that we created Mongo Ural here and here we can say the Ural off thes database. And basically, for this we need to right here. String mongo, two b. Then it will be a chi db. And then here, Kahlan and Deport. And 27017 is the standard port off mongo DB. And then slash and the name off the database. So basically, here we will have the database. Let's say ik I Now let's restart our docker, compose up and check how it looks like. As you can see, we're still are getting errors. And here it is saying current Yuri in your Istrian person is duplicated and will be removed to use the new parts or parts of bus option use. New parcel. True So basically, as you can see here inside, Mom goes in getting started. You have this option used new person. True. And I didn't write it because I thought, OK, maybe it will work without it. So inside to be here where we're making connect, we need to write coma and use new parcels. True, Let's restart it again. So basically these shows that you can work with Dr Really efficient You get some errors from Dhaka like in logs like normal errors on your machine and you can easily fix them. And it's not a big deal. As you can see now, after starting, I don't get errors. So here we have a P I and A PDB. They're awesome logs from a p I. D. Be and warnings regarding duplication like server discovery and monitor an engine in note. But actually we don't care about it because for not for us, it's important that who was started successfully by service. And this means that here inside index, we went through connect. So we're connected and on open with started our service, which means we're connected to our database and it should work. So once again, how it is working. So here we have our source index chairs. We have connected database and connect to databases Mongoose connect where we're accepting our DB. And then we just have on error on this. Connected on open on open means that our server, our database was started and we can start our server. So start server is just help. Listen and he ever get bored Host and connect db from our additional files. And in configurations, we have thes three properties from process. And so this three properties worse beautifying outside in Docker compose and inside our help of 40 b, we used this to be from Docker compose to connect toe database. Now, if we jump to docker, compose were added here. New image mongo latest. So this is the image that was downloaded automatically. So we don't have here Dr. File on on your EPO And he have we wrote Depends on a p I d be, which means this database should start first. Also here we're owed mongo db and then a p i d. Be. So this is exactly the service. So this is thes property. So we're saying that this mongo db Ural is common from this servers service. And here is the default port off mongo DB. And this is their database that we want to use. This is it. If you have any comments or questions, feel free to ask them, and I will answer them for sure. 12. Making database requests: in thesis video. I want to talk about making database requests, but festival I want to understand that you really understood what talking images are. So basically in previous video you saw that we just wrote here for our epi. I d be service image mongo latest and this is it. And I think for a lot of people, this is some magic because like, you don't get what happened inside. And let's check how basically this image mongo db latest is looking like So this is exactly the same. Like we created here our docker file. So basically, when people created this mongo image, they just created something like not from node, of course. But maybe from a boom to you can right here, for example, remove everything and right here from Mobuto. Let's say 16. And then they just installed what they need for thesis Mongol image. So basically. Okay, maybe they don't have this copy worked here and so on. But you can simply John all commands here like you did previously. India Linux server, for example. You can right here, for example, from Mobuto and then John. And here you are making something like Abd get install. And here goes, Let's say mongo and this is basically eat. They just installed Bongo in this syrup. Then with command, they can say that when this image will be built, we need to start Mongo. So they're writing something like Mom got, for example, to start mongo DB. And basically this is eat. So as you can see, it's no magic inside each docker file, and each image is just a set of commands which are there to build and create this image. And then you can ask me. But what's the difference then, between sharing such images through Dr Hub and simply share in some best script like where you simply write EP, get one good to be and so on off course, the main differences that sharing an image is sharing the snapshot off your Lennox server, which means like this is like your class and instances. So class is your image, and your containers are instances, which means you just share the image and you're sure that in this image, everything that he wants installed is the same everywhere. So if they installed Mongo DB version, I don't know 16. Then this version will be it there forever. It would never be changed to a version 17 or something because they have this inside the image. So I hope you understood that there is no magic inside images. It just a set of command toe build an image and then we're using this images to create our containers. So let's reverted to our note because we don't need to change the doctor file and check what we can do with our A p i d. Be So first off, all I want to talk about this mongo db here. L as you understood. This is the name off our service and this is the port. And this is the default port where mongo db inside this service was started and this is simply the name off our database we can use here different databases and it doesn't matter because mongo db will create them for us. What is more interesting is the supply db. As you understand, we get a so called link toe the service so basically we can use the name off the service between services. So, as you can see here in declaration off FBI service, we can use that like the reference. Two are the services and it is happening through network. But we will talk later about it. For us, it's important. Understand that here this a p i. D. B is really good because it's not something like local host or some I p address, because in this case, three separate debates taste the same everywhere. We don't need to change this year l, for example, for production or local because it is always the reference to another service. Now let's talk about making database request. So here we're already enrolled Docker compose a build. And you saw that for us, where started first are like I d be and then our host, As you can see, we don't have any errors. And now in our application off sky sores and the index here after start server, we can do something with database off course. We won't implement the whole application here in with nowt, but it least we want to check that This is exactly how a said and that a databases available here and we can use it. One more thing that I want to do here is Consul log our Deby because here we have to be inside our configuration And it would be really nice to see this year l in the consul log when we start our syrup. So I simply right here database You're well And here is Debbie. Now we need men early to restart our docker compose up. And as you can see here, we have here database your l mongo db a pie, blah, blah, blah. Which means our d b is correct. And now we can make that obeys requests. As we're using Mongoose, let's open documentation. So here is get started. We already made our first connection. And Wissmann goes, if you don't know, you are defining scheme us. Which means this is the schema for the model. And here you are saying you have Entity Kitty with name. Normally I would say for an application you have something like boast schema, article schema than user schema and so on. So, as you can see here, I will just based it somewhere on the top because this is actually not related. Toa do this on their start. This is like a definition. So let's say, here we have Kitty schema. Okay, fine for now. Now we need here toe import mint goes. So we're requiring. Here, mom goes and now human go schema will create kitty schema. Now, the next thing that we need to do is, as you can see here, toe compile schema toe the model. So basically here I want to ride not to our but Const. And this is our model kitten and Mongols model kitten Kitty schema. Which means schema is how our model is looking like. So here we have kitten. And as you can see, we can do some things with our kitten. Let's, for example, right this now after starts. Sure, Actually, it's still doesn't matter, because thes thing doesn't make a request toe database. But at least where, sure, here that we have database here. So let's name silence and new kitten and restart our docker compose up. So, as you can see here, you can see the name silence, which means here we created an instance off our model kitten and thesis silence and basically here What is interesting when we will restart it again? You can see that we have here an object with I D and name, which means this is already created. Database entity. It's not saved, but we can save it now because it is already created by Mongols. It has an 80. So let's check how we will save things in database. So as you can see here, we can use methods. We don't need that. And here we have fly fee dot Safe. So basically, exactly this code we can copy paste here council. Look, we don't need hopes. I want to paste it here. And he ever want to the name Fluffy in silence Because our kitten is silence. And here we are, right in dot Save where we ride. Call Beck and call Beck has error, and silence will be our result. Let's name it result because it's clearer. And now if we have ever will ride council, look error. In other case, we want to try it. Consul Log result. So let's restart our database. Our docker compose. Sorry. And as you can see, we get an invalid response. Actually, we could fix this problem before because as you can see, the problem is that name space doesn't look correct. So here we have single brackets and inside we have a tie, then double brackets and then dot kittens Basically, it should be a pie dot kittens result This symbol. The question is why it is like that. And the answer is one line before it is. See here the consul glogg database, your l and the difference between host and at the base near El is that here we have this double quote. We don't need them, actually. And this means that we didn't give correct value from our docker compose. So let's check how it looked like here. As you can see, mongo, Ural were wrote with double quotes and no, just like a string. If we opened this reference file on compose here, you can see that I am in the section off environment. And there are two different things how we can write an environment. It can be written like an object. So, basically, like here with Cullen or with equal sign and death here as we're voted with that here off course, we can't right the symbols because it will simply be a strength. If we convert everything toe such notation, then it doesn't actually matter what quotes were using, but in notation with dash. We should remove these symbols completely. Now let's restart our Dr com polls and check if it's working. As you can see, we don't get any errors. Now database Ural is correct and that then we see our result. As you can see, we have here I d name and thesis Simple V, which is equal zero. And this is actually a version. And this is the market that our record was completely saved correctly in the database. As you can see, we successfully created to services one with database and second with our A pie project. And now everything is working. We can, after starting of the server, use our database and it is working just fine. If you have any comments or questions, feel free to ask them, and I will answer them for sure. 13. Volumes: in previous video with successful saved this Silence kitty toe database, which means our database is working. But the question is what happens when we start our docker compose up. So basically, every time when we build again and again our container, every data will be removed inside and recreated again. So basically, as you can see here in our docker file, we have this copy dot dot which means every time when container is build, where coping again and again our files that we have here, which means every time we change just one file like this index jazz, then we start the container and all these commands DACA is trying to do again and basically okay, he's checking. We don't need to do npm install because we did it previously. But then he copies all files, which means basically was every new build will remove all files and create them. Julie. And this is exactly the benefit of the doctor because you know that everything is created every time from scratch. It's nothing left there, nothing a tall And of course it's good for testing purposes because we're sure that everything is installed from scratch. But it's not good when we want to persist information. And basically normally we need to cases where we want to persist. Information. First of all, it's a database. We don't want to remove database data with every rebuild and secondly, their sources off our project, as you can see now in Dhaka, file every time when we rebuild our image. Record p all files this copy dot dot means work up in all files off our project again inside the image and this is all fine, but we don't want to to build an image every time when we're doing change, it's just not efficient. So basically, when we hear change one string, we don't want to rebuild whole image. We want somehow toe store this data somewhere, but not inside the container, because basically, the changes are happening. And we won't just toe make this change inside Web server. This is it. And there is a solution for this, which is called volume. Basically, let's open the documentation. It's really nice here, and there is a section which is called volumes, and the idea is that you can mount volumes toe the service. It can be a little bit difficult, understand if you don't know what is volume at all. But basically the idea is that this is some additional place. It's not an image, it's not a container. It's a volume, which means it's the place outside of the container where we store some data. And normally DACA does not remove this data off course. We can do it if we want, but normally between rebuilds, this data are there. The second benefit off the volume is that we can use the state A between our services. Which means when we jumped to our Docker compose. And let's say we have data like I don't know, for example, database. We want toe use this database in serval several services not just threw a pie but directly using the files, and we can do it with the volume where just saying a cave we named this volume I don't know full and then we depend on the's volume into different services, So basically this is an idea, and here is an example how we can do it here. It's a little bit complicated because here is the full way off right in it. We won't write it like this. Let's try shorthand, Syntex. So basically here how we can share FBI database for now. So the first question is where data are and how we want to name them. Let's say that here would have an image. And now we have volumes, property, and here with Dash, we can write, let's say mongo db data and this is slash data slash db and I think mongo db data is not good name. We will change it. But basically, the idea is that left can be whatever it is. Just a name like full. This is Justin. Identify for us and slash data slash db This is the path inside container. So this is the path where this data will be mounted this volume. So basically, normally, mongo db database is here in slash data Slash to be. This is why we're Lincoln it exactly in the place where it is right now. And I think the name mongo db back I will be more understandable because he ever understand . Okay, this is the volume with mongo DB data. And basically, this is the volume that was initially created inside FBI or for a P I. Now there next point. So this is actually sufficient. If we want to store and persist data just inside this a p I d. Be but for sure Later we want to reduce them in other places. For this we can drive volume section in the route here and just right here. Mongo db a p i And here more should be a column at the end. So basically, this means that this is the name which will be global. And with this name in any this service that we have For example, in a pi we can use this volume. So basically, let's restart our docker, compose up and check what we get. So here I will scroll on the top from because it's important. And as you can see here, we have a word of warning service state I. D. B is using volume data db from the previous container and we need to remove existing containers to use. So this host Meppen does not have any effect. So basically, let's ride this command Docker compose ceramic I d be. And basically the problem is that previously we didn't use the volume and now we're using it. So for this we want to remove completely this 80 I d be. And once again John Docker compose up and let's check if we have any error. So here are no warnings and you can see that we successfully created everything and here we don't have any errors. The question is how to check if we have volumes are not for these. There is a command in Dhaka which is called dark volume. Ls actually you can right here, just aka volume and you will get a nice help. So here is usage, doctor volume and command. So here we can create volume of dunk need to do it by chance because Docker compose is making it for us. The reason Inspect last brune and son. So basically, let's try Dr Volume ls. And as you can see, I have lots off containers and normally I will have here volume name. So as you can see here we have a real world docker and one goody be a pie. And as you can see here, Munger, debate pi is exactly the volume that we created here. Now we can right here, Doctor inspect And then the name. As you can see here we can see when it was created some labels and mount point and so on. For now, we don't need this information, but basically you can understand that the volume was successfully created. I think that with a pie with it correctly, of course. But it was not that clear how cool it is and how it's all of our problems. This is why I want to show you how we can do the same for the files. So basically, for now in our FBI DACA file were copying all files on the build. And this is fine when we're doing a production build, which means we just right here Dr Composed up and these bills and start our docker compose . But the point is that we're also one development environment where were warned to change source files basically for production. We don't want this and I prefer to create additional file like docker compose jahmal, but for development. And here we can created Docker compose thought development dot jahmal. And now here we will write basically the same, but not that much. So he ever create services and we know that we have here at least ik I and we can overwrite something here we can override here Command with Yar. Sorry. In PM Ron Death and volumes And I will tell you what I'm doing in the second. So basically in volumes like previously were born to specify the path So the pathway will be a pie sores And here Colin and then user and here will be sores AP source. What is it about it all? So we have Docker compose and the idea off darker that we can by default If we just tried Good docker compose something It takes the stalker compose jahmal But we can also say docker compose minus f and then the file. So basically here we can save Docker compose jahmal and then one model quipped composed file as you can see for example, minus f Dr Campos Jahmal and then Docker compose development Yama. And then we're saying, for example, built up as always. And the idea is that in this case, take everything from Docker compose and we're overjoyed All properties that we defined in docker compose development with properties that we wrote here This means that basically would take everything from here but in a pie section oversold command and volumes as you can see here. We didn't have volumes at all because we don't need toe because this is production and for production We don't want to change source files, but in development of course, we want to change cells files. This is why we want to mount with the volume our source folder. So basically here source is mounted and this means that this is path in our system. This is a pie sores and does the right. You can see the path inside container. So basically we take the same path like it waas in Dhaka file and here the path actually forget to change it back. It is user source app And now here you can see that in development it is user source absolute sores because we want exactly the same structure. So what does it mean for production were taken file on the left Docker compose Jahmal for development were right in command like this minus f then production file development file and then the name off the command And here were overriding command, which means we have different command. So here, for example, we can use no demon and if you don't know no demon It is a tool for known jazz where we're start on every file change of observant and we have here volumes which means we can change files without rebuilding the system. And let's check how it will look like first awful. Let's install no demon inside our a pie. So we're going to a guy and here simply NPM install no demon. So I'm installing it and you can go, Go. What is no Demon is is And inside in PM you can simply install it for example globally we don't needed globally and then right no demon and some conditions or we can create configuration file for it and then just right No demon, as you can see with successful installed the package. Now let's jump to our sky package. Yes, we have here no demon. And now I want to create here and you configuration file where the conflict off no demon will go. So basically the name will be known demon dot Jason and this is an object. And here we have verbals and the verbals is false. But sometimes you want to have it in true. If you're debugging something but also have boards and this is their way. Where with 55. What folders do we want to watch? And for us this is the source folder. And here we have exact. And this is what command we want to execute every time when the file is changed there. And this is note. And here is sores slash index chess. So basically, this is executive to command that we share in our package. Jason, this is it. Now we have to create new script here it is deaf. And here we just tried no demon, which means when I'm jumping now here in a p I I can write and PM John Dev And it will start no demon as you can see. But off course we get an error because we're missing a lot off process environment of rebels because we aspect to find them online through docker compose and we don't need to start a program like this. But the point is that we successfully configured not demon. And now we can jump back and start Docker compose with development. So we're right in Dhaka comm polls then minus f docker compose Yaman. And here I didn't say it correctly. It should be once again minor self. So the next file, and then you are right in next file that will override it. And here we have built. So this is Docker compose minor self file name minus a file name and then the command. Then I'm hitting Enter and as you can see, where building things Also, as you can see here we have a paid to be used to Nimitz skipping. Which means DACA sees that it I d be was not changed. And we don't need to do anything here, so we just built a pie. As you can see, we don't have any errors. And here we have some warnings, but it doesn't matter, and it was built successfully. Now let's start. So we're writing up. And as you can see, it is working and our host is there. Let's reload the page so we can see that it is working. Slash Test is working, does not test our A pay service is working. So now I will hit enter several times to clean the screen. But my service still there. And now let's jump in a tie folder in source, let's say in index and here we can simply right, not result, but result with volumes. And save these and jam Beck. As you can see here, we have some changes. So basically, from a p, I will have a message. No demon, just starting Q two changes, which means we didn't build an image. But DACA So our changes here because threes and not demon inside the container and it sees the changes in this folder, and as this fault is inside the volume, it's not inside container. So this changes are happening just inside this volume. So we're changing in this file and this file automatically Israel or did earlier, large and Web Serra. So here, no demon just started no source index chairs and we're getting same warning as always, But basically our project was started, and here is result with volumes, which means now with every save our container sees the changes and our Web server is being restarted. So this is exactly what we wanted for development. Luckily, when we make some changes in the cold, our docker compose up simply shows us the changes. We don't need to rebuild containers or do things like we're doing it for production. I think that this example illustrates volumes usage much better. And the last question that maybe bother you. Why here? I wrote it like this and in development resulted like this. So here we have volumes in the road and he are not so basically, this is the named notation, which means where name in volumes in the road. And this means that we can reduce this volumes everywhere. Here, here, it's not named volume. It's in line volume where we're just using the volume in line, which means we don't need to re use the source off a guy anywhere. This is why we simply say in line. Okay, Please take this folder and put it here like assembling. This is it. So I hope you understand now how volumes are working and why do we need them as always. If you have any comments or questions, feel free to ask them, and I will answer them for sure. 14. Auth service: in previous video worked with our volumes. So now we know how we can use the data outside off our containers. So our a pie service Now, here's database inside. We were connected to the database and we can start writing code. So basically, our A pie service is now fully ready, and you can just right here any project or any a pie that you need. Now, let's reach toe our other service out syndication service. So, basically, as you can see here, we can copy paste everything that we have inside our FBI because we will use the same connected be. But of course, it will be other database, and we will also have start server, and basically, the structure off the files will be the same. Here will be Mongols and Connect. And here we will have configuration. I will copy the whole FBI two owls and just proceed exactly the same like we did with our FBI. So we have here a dr file from Node Working Directory, and we're making the same stuff. But basically, we're making this only for the sake off simplicity. Because actually, when we have service, this means that we can have completely unrelated technologies. Maybe we want to write the city I with Ruby on rails, so it's completely fine. Then here we will have DACA file, which will build our ruby on rails project. And of course, then we have another files here in the sources and even maybe this a pie folder who will be an additional depositary and some other team well maintained the seat I Which means this is the main benefit off the doctor you create small services are not small. This is up to you, and thesis services are doing single purpose. So, for example, our FBI service is just implementing a pie for our entities. And our authentication service may be written in other technology. If we want Toe is maintaining by other team and they are doing out indication there they can, even with the help of the DACA file here Iran thesis sky without all other services if they want. So let's now hear. My authentication folder is empty and I will just copy and paste a pie as out. Basically, we just do it for the simplicity because here we have expressed mangoes and known demon. So this is exactly some other service where node is working. So let's check if everything is correct. Here we have our unknown demon for development and we have exact four sores. And here we have configuration which everywhere everything is stateless and this is the benefit. We could just copy paste the folder and we don't need to change anything because all configuration is common from outside. We will also use here mongo, db but the other database and completely other service. And also here in our index, we connect to mongo DB. And here we have get test. But this is authentication, so let's right here our authentication. Sarah is working correctly, and now here started out Indication service on port and here will be our port. So this is basically eat here. We can actually remove the things that we have with kitten and kid and safe because we know the database will work. So basically, this is just an example how our project can rebuild with database and services. So basically, now here I am almost clean. So here is our syndication service boilerplate. And here we have connected database. Now let's check the docker file. This is exactly the same working directory. This is completely fine because it's completely another container we're using here. Note CO P and P M install everything is looking fine. Now let's jump to our docker Compose. So here we have a P I and D p i d. Be. And I want here to create two more services one for syndication, a p I, and second for our syndication database. So basically now, as you can see, my doctor composes running. And now, when they jumped to the console, I can dry it Dark ups and Tokyo PS means Dr Processes. So these are two processes that Iranian now the 1st 1 is our container visit pie. And the 2nd 1 is container with database and here at the end. So this is the boards and this is the I d and so on and that that you have the name. So basically name Israel World Doc ap I minus one And here a p i D B minus one. So basically the names are not that bad, But just assume that you have like, several projects in your machine. For example, I don't know five and you have the critized every project and inside. If have services like 10 or five maybe and then in Dhaka processes you she, like, really like 50 containers. And you want really to distinguish what service here or what container is related to what service And then you can, for example, check what parts exposed here. What command is using is and so on. So this is useful, but we want to make it more readable. So basically this name is not 100% readable. Off course we can understand it, but basically the idea is that in every service we can specify the container name. So let's say now a pie were saying container name equals and I like strict rules off naming , which means I am naming everything with the names pace off the project. In our case, it will be riel world dash doctor, and then dash the name of the service. So in this case, it will be a p I. Now let's copy container name to our a p i d be and name it slash Keep I slash db So now let's restart our docker compose and check what names are. So let's run once again and you see here that we have normal names like we provide it now with this names, It's much easier to work and understand. What is this container and bound Now? Let's start with describing our A pie service. This will be a pie for our house indication. So let's name it. Let's say owls and I think this is sufficient because we know that our city is only related toe authentication service. Now here we have built and our build is watching four hours Indication project, Which means this is authentication folder and there is Docker file inside. Now let's talk about container name. We're making the real world, or can, as the prefix and service name is out indication. Now what command will we have? And here we have in PM Ron start exactly like in our a pie service, because we're right in. Now the file for production next one is Wrist Heart. So let's arrest art unless stopped. We already talked about this option just to remind your the container will be automatically restart if it was, for example, not started correctly or Dreesen era. If it was not stopped the next point, ease our a port. So basically, here imports. We can say what poor do we want to expose? So let's right here. The 3001 and let's map it to 3001. So which means three solvent one will be our port inside and outside. Now let's talk about environment. So here we have our port, which is 3001. Now we have our host. I don't know, actually, if we need it or not. So I will just roll string here and they think later we will remove it a change it if we need toe and the last. The most important thing is the Mongol Ural. So here among the your Ellis Mongo DB And here we will have not a p I d be, but owls DB and it will be additional service for authentication. So let's provide here our port and let's name the database out. I think it's sufficient. And now we have our block regarding authentication service. Now it's time to write authentication to be, I think also DB is really nice name. And here we just have the same like we had for a pie db. So we provide our mongo image. Then we have contained a name. It's really world. Okay, this is our DB. And now we have volumes. And basically, in this case, it will be Mongo DB House and the Ural inside. Our server will be the same day to DB. And now we should adhere. Named volumes Mongo DB owls and then Colin. So basically, as you can see here, we added new owls to be and we added New block for authentication service. Let's check if our docker compose is still working. So let's stop our docker Compose and simplify Dr Kam. Polls up minutes, minutes build. So I don't use many self here because I don't want to test our development environment. So now we're building our production. So here is you can see a lot of our started we have Here are two b and F B I d be and let's scroll a little bit on the top to see that everything is fine, as you can see here there were three lines about our owls that started authentication service on poor 3000 and our host ease and this is the Ural that we provided. So basically looks like like it works. So here we were connected toa are db and let's check on the top. Normally, if you have some warnings, they are on the top. So I will scroll here more and as you can see successfully build successful attacked a pie latest and so on and we have attaching and they don't see any errors. So basically you also can see the line created volume and here is one good to be out. So basically Docker compose created magically for us volumes because we described it here like a named volume and he created thesis volume. So now the data off their off indication on database will be persisted inside the volume, so looks like everything is working. And now let's jump toe armor browser and dry 3001 slash test. As you can see, here we have our authentication server is working correctly and now we can jump to 3000 0 and our FBI survey is already started, which means we're coming to the moment when we with one command without installation, anything in our own machine can start working on the project which has like different services inside, and it just works out off the box. You don't even need to know what was installed. If you have any comments or questions, feel free to ask them, and I will answer them for sure. 15. Frontend service: we're already implemented our FBI service and authentication service. Off course. We will implement them a little bit and see how the services can work between them a little bit later. And in this reader, I want to focus on our front and service. And actually, it's a little bit tricky. As I already said, Sit up in Dhaka can be treating so basically takes timeto understand all properties, understand how to put your project inside. And from my point of few put in the front and part off It is the trickiest part with working with dark hair. And you can ask why it is like that basically, in lots of projects like, for example, create wrecked app when you just install it off course it is working out off the box. But you have such nice things, like working with interactive console. So, for example, when you start create raked up like this, you will get a message like something is over to the Iranian in your ports 3000. Do you want to start it on another port and you're simply click? Yes, And it is starting on another port or, for example, that a create wrecked app or another tool which are also popular like, for example, for Angela, where you start in Geezer Va and then was long Poland or, for example, with Web sockets. It will update your changes magically on your page result reloading. So basically, you don't need like here in our it guy heat every time the Lord to see your changes. I can't really say the time Defend off this hot mantra lording and at least three Lloyd in page when it wants in front. And but actually, if we're living in Javascript world, we can't go another way, so we just need to work with it. So let's install now our front and part with create wrecked app. So basically, if you don't know what is this? Create wrecked Deb, is there special tool which installs for you react with all dependencies. End of observer. Which means you just write one command like and peaks or in PM, create app, my ab, And then you just get the folder with boilerplate files and you just need to write cold there. So here you can scroll toe npm section and this is how we create a create rector app on our machine. So let's just jump to the console. I am inside Riel World Doctor Folder. And here I also have front and folder. It's not working like this, so we need to remove this front and fall the first. And then we can ride this command and pm in need react ab And now here will be the name and our name will be front. And then I just click front and and, as you can see, create wrecked app and installs all dependencies and then our front and folder will be created. So we just need to wait until all files will be installed. And we're good to go. Create reactive, successfully installed old packages. And now I'm inside our front and directory so we can see our files. And now here we can write NPM start. So with this command, as you can see, we have this interactive console, so basically create tricked app asks us there is already something running on poor 3000 and actually this is darker. And would you like to run the app on another port instead? And we're just saying yes. And now in the browser, we get this Ural local host 3002 and here we have aided source app and safe toe the blood. So basically, when we jumped directly in the console and go to the front and source and for example, FGs. So here you can see some strings that you can see here, edit sore subjects and save two relied. So let's put some banks here and then you just which toe the browser and you get this text here. As you can see, our create react, help is working, but it is working in our machine now. We need somehow to adjust it in the way that we can use it inside Dhaka. So I will quit from their Web Serra off our front. And for now and now we can jump inside our docker compose file and try to create new service for our front and and basically sounds things will be similar like we did before. So we have here front and build folder and then we have here contain a name which Israel world docker and here will be front end and also we need ports and as you saw by default great wrecked app is Ronnen Import 3000. So basically here. We can write 3000 3000 and then here we will change it inside our FBI. So here we can't have the same port. So inside it is 3000. But outside it will be then 3001. So here, let's make everything similar. And let's stick to the same name. And so we have everything. One here port is one specified. So it is one inside and one outside. And the same for authentication Portis to then here we have to. And outside. We also have to Now, this is it. Our ports are specified. Now we need to add restart property. So the start will be unless stopped. And we need our property for command. So basically, command will be in PM start. Actually, we can write always in PM Ron, start for the sake that it is the same everywhere. So our command Andrew start is there, and if we will try to start it now, it won't work. And the question is why? Because we should have problems with this interactive console so we can try to start it now . But basically it won't work. I already tried, eat and I get a problem within Directive council. And then I Googled it and the reason air issue in create tricked app with three x script. So basically, it says that a new version of Rex Creeps and actually it was not so long ago was failing to start inside dock him. So basically, the point is that we need to specify special properties for our docker compose to say that we want interactive console. So here for these were saying as today in open and it will be true entity U equals true and you can check if you want this issue in create wrecked AB And basically the solution with Docker compose was exactly to provide. This thing is here, so this is really important because we have hot Montreuil Orden inside create wrecked AB and we want to have interactive council. Now let's try to start our docker compose up as you saw I already tried it and it is breaking because we have a narrow cannot locate specified DACA file, which means we didn't create DACA file inside our folder with front end. And yes, this is exactly eat. And this is why I like docker compose because the message is off. Errors are really understandable. So basically, let's specify in our front and folder docker file, because without Dr File, it's not a service and actually want to copy base here, doc file because I don't want to write from scratch, which means we just take the doctor file that we already have when stall inside known. This is really important because another case, we can't install node models inside for our front and we have a working directory here. We copy paste our picket Jason, as you can see inside front And we have also pick a Jason with script and so on. So we're runnin NPM install and we Korpi old files. So now it should be enough to build our front end. As you can see now we're building front and co open all files and in style in packages with node inside their container. As you can see, all packages I installed, our images were build and now we see the message that it was started successfully first Awful. It's really nice to look inside docket ps to see processes. As you can see, we have lots of processes. Fourth indication FBI then fronton our DB and HKTB So everything seems to work And now we can open create raked ab on local host 3000. But of course there are minor changes that we want to do. First of all, as you can see, this is the development built. So basically here we're in production. So Docker compose Yam is for production. It is fine to test it like this but basically later we want here not development Web server but just build it for production and maintain eat s static CSS and JavaScript For now it is working, as you can see but our volumes are not there. So basically we didn't write anything regarding volumes, which means our changes in code won't change anything. So let's adhere volumes just for the simplicity off testing. So basically, in the same way like we did for our development, I will corporate for now. Volumes here inside front and part just for the sake off a quick test. So as you can see here we have a pie sores. We don't need it. We need front and source. So now when we change everything inside front and sores, we will update it in user source A pie source. This is fine. Let's just restart our docker compose up build. And now when we change some files inside front and falter, it should be automatically changed. As you can see, it was compelled successfully. Now we jump to our FGs inside our front and and let's right here he low from inside Dr Just Save. And I even didn't reload the page by myself. But you can see here that it was updated with our string that we provided here, which means now without the build with the help off our volume that we created just with single line we can update code in front and and it is compiling successfully, which means our front and is already ready, Toby written. And if you have any comments or questions, feel free to ask them, and I will answer them for sure. 16. Running frontend in production: in previous video we created our front and service and it is working. But we did it really raw because here is our production con fugue and as you can see, where writing things which are related to development. So basically, just to remind you this file is only for production. If we want to override some properties for development, we override them in our additional jahmal with DOT development. So basically here now in development, we have only some of rights for guarding our it guy. So we need here to add also things about front end and maybe about us. But first awful. I saw one property that is missing. So as you can see here in FBI, we have depends on a p I d be buddy Now, we didn't write this here so let's based it now. It should be. It depends on and here should be ours to be. You can ask yourself what will happen if we will remove from here? Depends on. And of course, the answer is that Docker compose doesn't know what order do we need in the services. So docker compose will just start a services as it is like from top to the bottom. And this is it Basically, in the case with depends on Docker compose understands. Okay, our service is dependent on ours db Which means first we need to start out to be. And if it won't do this, we will get errors when we start Doctor composed because authentication data base is not there but we're trying to connect to it. So this is why we need here. Depends on off to be Now let's go back to our front. And so here everything as it waas we have here is to the open and tt you and this we need for this interactive observer from our create react app volumes were also need only in development because we want to change files Onley in development. So the question is, if this file Israel regarding production we didn't write things correctly and this is for sure Eat. The question is what will happen if we jump to our front and folder and Ron and PM Ron build. This is the command which is designed by create racked up and as you can see here we get a message. So creating an optimized production build compiled successfully. So we compiled our front end and hear of files that we get is a result. And here some messages like Toby, the build folder is ready to be deployed and you may serve it as a static server. And exactly this we want to do We want to serve our server as aesthetic. What does it mean? Off course. We don't want hot mantra Lord in production if we check here inside our front and build So here is all things which are related to production. So basically here, as you can see instead IQ with KFC assess NGS and basically here our main shares is with bundled with all packages that we need, which means we don't need no more deals, source or whatever can remove all files except off the built folder because only this folder is needed for production. So basically we want to start in our production our server, which will serve static files. And here is a nice example how you can serve and start static server so we can install package which is called serve within PM, as always, and we can build then so self minus as built Buildings folder where serving everything would, which is in the folder. So basically here in build, we have index html it is magnified. And here we have some dependencies for our aesthetic for Shia says JavaScript and so on. So this is exactly what we want to do. So basically, to test it on our own machine, we can write in pm install global and then here you are right and serve. And this will install serve package and your machine. And then you can start with this command serve minus as build and then it will start. As you can see on Port 5000. If we want to spit C five board, we can ride minus l and then the port is you can see it also works. And now on local host 3001 we're handling our magnified. You can see it in sores. It is magnified html where we have our unified CSS and JavaScript. So exactly this we want to create inside our doctor compose So basically, let's check. What do we need first? Awful. I want to jump inside front and folder and look on the docker file. What do we need to do here? Basically we want first toe, build our sources and we can do this by Iranian in PM John Build. This is exactly what we did here. As you saw. First of all, we're old in PM Ron build and then regard this build folder and you can say OK, but why? We're right in here. We're using Docker file for production and for development. And you're totally right. If you don't want to do this built in development because actually you don't need to you can create two different doctor files one for production, one for development. For the sake of simplicity, I will just stick dewandaka file and actually, yes, This command is not needed in development, but it won't take that much time. And we're not building are images that often so this is fine. The next thing that we need to do is to install inside dark hair this serve package. So basically, after this, we can right, Ron, in pm global serve and not server but serve. And this will install this package after building the image so it will be available inside . Now we need to jump tower Docker compose in change our command. So for now it is NPM Ron Start. And this is not what we want to start. We want to right now. Serve like we did here. You remember Serve minus has actually we can copy paste it so it should be served minus s Build buildings a folder. And here is 3000 port basically exactly the same port like it was here. Then I will comment out everything that is not needed for production. Now let's write Docker, compose up, build and check if it's working. I'm getting here a narrow that service front and fell to build and PM minus G serve return zero cold. Obviously I just made a mistake, you know, a doctor file. I forget to write and pm install. So this is no command. This is why I am getting a narrow As you can see you this time I don't have any errors. Now let's crawl to the top. At some point, we should see something which is related to serve. So as you can see here we successfully build it everything. And now somewhere serve should be started. So here is a pie and so on. And here should be front and is it. Just see I can't see anything which is related to front. And but there is a special command to see the logs off the container. So we know the name of the container it Israel World Docker Front and I will copied. And now we can ride DACA logs. And then the name is You can see here we get an info except in connections and at in shoe TPS local host 3000. So basically, this is all logs that we get from our real world front and but looks like it is working. Let's reload the page. And as you can see here, we're getting our page. Now let's champ toe the sores and as you can see, it is magnified. So it is exactly what we prepared. Now let's check if our front and still works in development. So for these, I want to copy everything that they commented out to our developed fire ill. So here is development, and here we want to create service front and end of a ride inside several properties. So this is how it looks like here is empty space just for reading. And here, first of all, we want another command. So here the command will be in PM Ron, Death. As you remember, This is our death server. I hope so. Or maybe I'm drawn in. Beckett. Jason, we can see that our command is start not deaf. So deaf commands we made in our AI projects. But this is create wrecked app. And here it is. Start. So I'm jumping back to develop and here is in PM rants tired. This will start a death server and here we have our volumes. This part is really important because we want to change the files on the fly. And these things are important for our console. Now let's restart once again our docker compose up and here we need basically, I want to start it not for production but for development. So it should be minus Have docker compose jahmal minus seven Docker compose development Jahmal up minus minds built on Dhere. We're getting a narrow because I'm in front and folder and not in correct folder. So let's start again now it is working and let's check if it's working with update in front and as you can see here, I'm getting in their logs that our front and service. It was started and you can already see that this part is from create wrecked app and this is not production. Build one with a lot the page. Now it is, hopefully their development part. So let's check If it's so, let's jump to front and source and objects and right here Hi, I'm development, as you can see here, my page waas automatic little lauded and I am getting here the message So basically this is exactly an idea. So here we're right in everything, What is possible and on the right in development Yama were override in things that we want to make differently in development, this is much more easier than toe. Just a support. Two different files which are completely not related. So we're trying to merge them as easy as possible. As you can see our front and this successful Iran and in production. And if you have any comments or questions, feel free to ask them and I will answer them for sure 17. Docker exec: in this'll media. I want to talk about magic at least I hope you understand that there is no magic Insigne doctor and I can show you some things which will show you that there is no major conductor completely. So basically here. As you can see, my doctor composed Israel in from previous lesson and in consulates. Previously we can drive Docker logs, for example, or daki ps. So Doc Ups is showing our containers and DACA logs. And let's say with the name off rial worldy chi, we can see what do we have in our locks? So is it concedes much easier to understand the logs here, then to see them if we scroll them in Dhaka composed as you can see now, our create wrecked app removed and blocked completely the screen so a can't scroll back. So it cleaned all locks from the screen. So this is why the lager from Doc itself is much better festival which she thinks on the related to one sarees. And it's easier to the bag and you can see here, for example, started a pie on the port 3001 and so on. Now I want to show you one more command which is named DACA exact. And what does it do so DACA exact and then minus I d and then the name off the container. So this is when we want to execute some command inside our container, Which means when we just make something like air for full in our machine this command is happening in our machine. But of course, sometimes we want to do some commands inside containers And the most popular command that I am doing always is the command to go inside container in a shell because basically you don't want to just write once Foo Foo and the toll normally want to jump inside container, check some files, check some logs, change something and so on. So basically toe go inside the shell off container You need to write DACA exact, then minus 80 And here will be the name off our container. I took, for example, a pie and now as a judge which me and shell and we're hitting here and here and I am already inside container. So here we can write, for example ppd and you can see the time in the user source app And you can ask why? Because here inside FBI inside our docker file whispered ified our working directory. And here when we ride, Alas, you can see that we have files which are related to our project. Basically, all these files, except of sores are corp it inside with this command copy and only the source folder. He's working, as you can see, not here. But if we build it as for development, then this folder will be inside volumes. But basically, still, you can go in source and see what is there. Check the content off the file, for example and so on. So the idea is that at least you can jump like this inside container and do some things first. Awful. You can understand that container doesn't have any magic, so you can jump to slash and see that this is just completely standard. Lynn looks like nothing a tall, new and down. We're going inside our project. And as you saw here inside a pie, it waas user source app And this is the folder that was created source EP. And in this folder our project is living and basically here. We can do whatever we want, maybe start something and so on. But this is really nice approach when you need to check what files do have do some commands inside container like, for example, feel dating database and so on. So basically toe go out, you just write exit And once again, Togo in Dhaka exact minus I t than the name of the container and the command off course. You can join just right here for food, but it won't give you a lot. Yes, it chose full and this is actually is the output from your container. But normally you want to jump inside and do something. If you have any comments or questions, feel free to ask them, and I will answer them for sure. 18. Setting up nginx: in previous videos with Successful set up Our Services for Front and A P I and authentication. Now it's time to talk about how we will excess the services through browser. And why do we need engineers here? I hope you already have some knowledge with in jinx, and if not, then you can just open in genes, for example, Wikipedia and check what it is about. So basically, this is open source, high performance issue to be server and reverse proxy and blah, blah, blah and raw millions off features. There basically for us in jinxes important because we want somehow to manage all our services and what I'm meaning by that. For example, here we have local host 3000 So let's assume that we're on production here. So my machine now is a production server, which means, yes, this is fine. We're exposing 3000 port, but for now, this will be then some AP like photo AP A. Have and then colon and 3000 off course. Normally, people won't try something like thes in browser. To access your website, they will write some name like riel world docker dot com and thistles. How Internet is working. You have a domain like real world. That could come, for example. And this domain is registered in some registration. Which means there you assigned that their bindings between this domain and your AP address , which means basically your registration knows in what AP He should transfer the request when this domain is triggered, which means we're right in thes but basically inside it is going toe. My p like this is where my service Ranaan a terror i p And here is a colon and 80 and basically it is always a T. This is how Internet is working. So by default, the default port is 80 and we don't see it. So this is why we're right in just the main and the request is going here. So this is our A p and then 18. And the question is how we can manage all these services if we just go to our 21 Port 80 and we even don't know. What should we do with this request? So, basically, this is where in jinx come into play. So we have a domain and in jinxes, something like proxy between all domains and all requests which are common in our A P address in our server and then in jinx checks. Okay, this thesis, this domain or this is this project and then it proxies this request to the specific project, which means in jinx, is something like a gateway between all requests all over the world and our server sold. This is why we want to do everything through and Gen x, which means, for example, we have some domain. Let's assume riel world docker dot com or, for example, for local. We will use something like DOT local. And then this request goes to In jinx, we will create in jinx as additional service and then in jinx, conflict inside is configured in that way. That it knows in water service is should give a request. For example, if it is something like slash full, then it should be triggered in front. And but if it is slash e p I, for example, slash full, then we know that this is related to our EP A, which means old requests West, which is starting from slash AP. I I'll go into our FBI service, and if they're starting with slash owls, they're going toe our service. All other requests are going directly toe front. And so this is the idea. Now let's implement our in jinx, so you will see how it is working. So we want tohave in your service here at the bottom. I'm creating you service. Let's name it in, Jenks. And the image here will be in Jenks stable. Hell pine. So basically, as you can see here, I didn't create any folder. Additionally, Friend Jinx, we will create it later. But for now, we don't need toe. Oh, here We just have an image which means now Docker compose knows we need to register the service and don't Lord this image. And just to remind you will pine here means that this will be the small image. This is what what we exactly want. And here is our container name. It will be real world dark hair and here in jinx and we're almost ready. We want here toe map our ports like with it previously. And we want here to map 80 toe 80 which means 80 east. The port where in jinxes is running inside our service and 80 is the port on our machine where the in jinx from service will be exposed. What is important is that I think maybe on your machine something is already using Port 80 . So I recommend you to it list. Check if you have in jinx on your machine running because normally in Jinx takes this port . And if it is, then you need just to stop it because it will conflict with our in jinx from the service. Now we want to create configuration for our in jinx. So for this, I will create here in Jenks folder for injuring sarees. And here we will have in Jenks Corn dog prod. And you can ask me why prod? Because later we will create one more conflict for our development. So let's check. What do we need here? First off, all, we need a service section and here we'll listen on 80. So this is the standard thinking. And here we need a server name. Basically for us is doesn't matter. But let's right here, for example, the same what is written inside our project. So here we have rial world a camp. So whereas human that our host Israel world now here you should not forget semicolon and Basically, this is Eat what we need then we have location sections. So what Allocation sections here in location. You can specify. What are you doing with specific request, for example, we can say OK, we have here slash a pie and then thesis case. We're doing something with pleasure. Bye. For now I want to start with just slash. Slash Means that all requests are going inside. And here we want to write proxy pars on Dhere. Http. Front end and here. 3000. This is it. And now we need to talk about it. So what is proxy pass? As it's obvious from the name it is proxy in their request to this thinking. And basically, as you can see here, this is a shoe TP front and and then 3000. So you can guess This is our service. This is this service front. And and this is 3000 port. What is really interesting is this issue tp front and basically off course outside on our machine or in Internet issue, tippy front and does not exist. But DACA and docker compose. Allow us through the network to build such your else and to use them and this is really the killer future. From my point of view off Docker compose because for now we can use some things which exists on Lee inside our containers and not outside. And we're communicating between services through the network, and this means that everything is super scoped from the server itself. Now we need to use this file and the question is, how very easy with volumes. So here we can write that we need to register volumes also in line. So like Dash. And here we're here in jinx slash engines conflict broad. And this file we want to put inside this service in DTC in Jenks and here configuration dot de slash ingenious con. So basically, we want to override this file in Jinx Khan with our configuration off engines. Another thing that we need to do here is to write depends on because, as you can see here with road inside in jinx location, proxy path and if this holds won't be available, for example, it is down. Then it will break. We don't want into Drake, So here we will dry it front, and which means we need to start front and first in order to start our engines so this should be enough for us. So let's get started with our doctor compose. And first of all, we want to test our standard production build. So this is up build and let's build it now. So here, my docker compose up is started. But as you can see, it's difficult to see. Hear something because we have too many locks. So this is why I wrote Docket Blog's and then the name off our in jinx service like Real World Doctor in Jennings and hit Enter. And here you see logs specifically regarding our service is you can see here we have a for an error unknown directive server name. So I didn't write it correctly here between seven name and the name. We should not put a column here, so it should be written like this. Let's restart it again and check if it's working. And one more thing that I forget to change here, sir, Name should be there really host show. So it should be not just real world DACA, but off course dot com If we jump now to our browser as you can cereal were doctor that calm off course. This is not our domain and we didn't buy it. So how we contest with this domain? Our server. So basically here were saying the server name and in our UTC hosts file, we can specify our name, so it will be approx it on our local host. So basically, if you don't know what assholes, This is special file. You can read about it in Wikipedia, for example, this is the host name. So we rolled their ports and hosts in this case is you can see here you can write This is local host and on the right, the name that we need. So basically we want this name toe be resolved in our local host, which means we can simply right here the line like this off course resulted shoe TPM so I just could be pasted it. And then this domain that we wrote here won't look in the Internet for this domain where it is registered. But first of all, it will be trying to resolve it in the local machine, which means we just kind of hacks it to be resolved in our local machine. And this is really nice for development locally when you want some domain toe test, for example, real world DACA dot lock Oh, you can just write in hosts this file and then used his domain normally in and not local host. And basically, as you can see, after adding this line to local host magically were jump into real world DACA calm and we're seeing our front and service. So let's speak once again, how it is working at all. So basically, when we ride this line inside our UTC host, Or maybe if you are in Windows, then you can just google for hosts file windows. And if I remember correctly, this is insistent folder on You can check in some link system than drivers. You does she and there is this host file. So basically there, you need to add this line that you want to resolve this domain inside local, and then this domain is going off course to port 80. But we don't see that this is the most important point. And now hear if I will close hosts and open our in Jennings. So here we're exposing. It's our in jinx to port 80 which means when we're right in here our domain or the main 80 . Then we're going inside this in Jinx inside Dhaka, inside this service. And then we go to our in jinx conflict file. And here we're now. Okay, this is our several name. And when location is slash, we need to proxy pass it toe issue TP front and three solvent. And this is our service, which is started. And what is more important is that now, here we don't need to expose the sport. Why is that? Because we needed this'll for our host, for our local machine. What you see here in configuration, this is not local machine. This is special darkened network where all services can communicate together, which means we don't need to expose any ports. Dhaka has excess fora such things. This is why when we just stopped and rains told I could compose up again, it will work completely like previously because this is the proxy Pasto the service. It doesn't have anything to do with our host. Yes, of course. We can have the sports to expose it and to use it outside. But actually it doesn't make any sense. So we're here in production. So we're testing production mold and this is our domain. And as you can see our front and is working and the same we will do for local. So we just write another domain toe. Our hosts file, for example, that local and then here. We also don't need to expose any ports. But of course, here we will have other commands, but it will jump toe the same front and syrup. So here I restarted, my doctor composed. And as you can see, it worked as previously. So basically, as you can see in this video with the top tower in Jenks, which is nice, it's not inside our machine. It's inside Dhaka. This is additional service, which is just bind it toe 80 port on our machine and then inside. It manages all services by its health. If you have any comments or questions, feel free to ask them, and I will answer them for sure. 19. Proxying api requests: in previous media. We configured our in jink service so we can now render our front and on real world dot com domain. In this video, I want to talk about a plies and how we want to proceed with requests. So basically, what problem do we have? So let's assume that we don't provide public a pies. So we just create some website and not some A project where people can access our A pie from outside and use it, which means our FBI is just for internal purposes. What approaches can we take for implementing E P I and what exactly do we want to achieve? So basically, let's say we're right in front. And so we're here inside our create wrecked app and here with have some app function, for example, whatever. And from here, at some point, we want to get some data and we're right in, like, fetch or access or whatever library you prefer to fetch data and here should be some mural which will get the data from our FBI. So here's some mural from our e chi and here, for example, slash post that's a rebound post. Then we have some cold back where we get this post and here we're doing something with them like set State, for example. And here is posts. Basically, this is the first approach that we need. So from our front and service, we want to communicate via http with our A pacers. And then we need exactly the same. For example, in our A pie service. Basically, our eight by service doesn't need to do anything with fronton, which means our EPA is just there. It communicates with database, but at the point when we want to check current user data, we need to get data from authentication service. So here I am inside our FBI service. And let's say that on initialize off our service, we want to fetch something from our reply from authentication, which means here some some euro from our house. FBI is needed to be supported. Also off course. It's not said state here, but we're doing something like we're getting back. For example, current user and you can ask why we're getting here. Current user, Let's say that we can excess, For example, some posed on Lee when we are the creator off this post, which means we need to check if current user when we're locked in with the current user is the same, like the author off this post. So this means our syndication FBI needs to give some excess for our empire. And also it had happened that our front and want to fetch current user directly from authentication E pay, which means it is like front and doesn't need to be used by anything but it. I is needed to be used by front and and our authentication is needed to be used by front and and e chi. So this is exactly what we want to achieve. And in this video, we will try to do something like this first ofall, let's create our test a pie where we can fish some data. Let's start with our authentication service. So here we have index and we created here our route with slash test where we sent some texts just to know that our service is function properly. Now I want to copy this and here we want slash current user. So basically I will keep it simple. I won't implement the whole logic about current user chicken talk ins and database. I simply say okay, I have get current user request and it can be, for example, valid or invalid. So basically, we can simply say here, arrest Jason and we return here an object off current user. Let's say it has some a d 123 and we have some email, and it will be full at gmail dot com. So basically, we have just based data off current user that we just send their. Now let's check if it's working. So for these, basically, it should work out of the box if we start development, Sarah or we can do it, for example, with build. But then we want to wait until full build is ready. So let's check in browser. Here we have local horse 3002 slash current user and we're getting our empire request back . But off course, this is not what we need. What do we need? So we have a domain riel world, or could that come off a local? We will have dot loco, but it actually doesn't matter. The point is that we want to excess this your l, for example, from let's Start, for example, of with EPA service. So basically we're here And he ever want to make a request for this? Your l and of course, local host 3002 is not correct, because in here we don't know anything about local host A towel here is we're inside Dhaka , which means we need to communicate with other services through the Doctor network. And here we can do it in the same way. Like with did in Docker compose when we rode here, this manga your l As you can see here, we used the name off our service in the same way we can do it when we fetch data from one service to another. But to make it flexible, I want to configure everything through environment variables. So here I am in a pie and I want new environment variable, which will be called, for example, owls apply Ural, and we take it from process environment, owls, FBI, your l, which means our service still doesn't know anything about configurations. And this is of course, good. So let's create this property now inside our docker compose. So here I am in the bad service, and here we have environment variables and we can say here that hours a pay your l equals and hear what we want. So here will be http than ours. And the port and our sport is 3002. And you may think that this is related tothe e sports, but it's not. And we will remove the sports from here because we're talking about boards off Dhaka network, which means this is the port where application is running inside Dhaka and the sport is 3002. Which means this is why here is also 3002. And this you can see we're using here, not local host to something. But this special hosts from Dhaka and this is the service name off authentication service. And actually, we want here aus ap a Ural. So it doesn't make any sense here to just write base. Ural, we want here slash ap I And then here let's jump back in our FBI and in source. And here when the service started, I want to Consul, log our owls a pie, Ural, which will be house a pie Hural. But now we need toe imported here on the top. So it is Kama hours a pie, Ural. So as you can see now it comes from environment variables and now we can use it here. So let's restart our docker compose and see if it works, as you can see here now we have in real world okay, by a line. All three pair your URL is http aus 3002 and a time which means this environment variable is there and now we can fetch data. And to do this we need to install additional package inside our FBI. This is called excess. So basically, if you don't know what this package is doing, it is really nice Package for front and and beckoned, which means for a JavaScript inclined and known GS where you can simply fetch data everywhere. So you just install it and then you write exhales get, then some euro, and then you get a response. And inside response you have dot data. You can make catch and sound. So this is really nice library. I'm using it everywhere. So he ever want to install it with NPM, install excess inside our FBI folder. Now we installed it. And here let's check how we can make a request from our ape I to our South FBI So for these I will create in your out ab cat. And it will be, for example, test with current user. Which means the idea is that this is some a pie and point where we want to get additionally data off. Current user. So this is just for testing purposes, of course. But it will show how we can excess our service with authentication inside our empire. So basically here we have requested response and we want to make a fetch request. So for this, we need here to import excess and this is required excess. And now we can make our gets requests. So here we're making excess get and we have here excess toe hours, a power your l. And as you remember this is this your l So here we described it. This is a slash a pie, which means if we want to excess our current user, we need the Ural to contain slash pay. So let's jump in sidles indication index So here we just created slash current user, but it should be slash ap I slash current user and then we return our user. So this is what we want to fetch here so it will be request with a slash a pie. And now we can get in eighties it with part current Hughes. Um, And as you can see in the commendation here, we get then and catch. We will just right then here and here we will get a response. So response is an object with a lot of properties, but for us is interesting. Onley response toe data. This is exactly where response data is handling. So here we want rez. Jason. So we want just to show something on screen. And let's say we're saying here that this is something related to the test with current user. So let's just return this to true as variable. And we want here to show current user data current user from our and here, let's say response don't data. So once again, we build inside our a pine your drought where we fetch first our current user from our authentication route out Indication service. And then we just used this response data to show something to user when we fetched this test was current use. Um, so it looks fine. Let's restart our docker compose and see if it's working When they look in browser Here is local horse 3001 test was current user I get can get anything because I forget here to put slash So let's try once again. Now, as you can see, it is working as planned So here we're access in our else indication but internally were fetch and current user from our service off hold indication and will return some data off current user here, which means this is really nice approach off working between services. So, as you can see, we don't need to do anything we just need in our docker compose yah mo to specify correctly , for example, a pie Ural. And then we just build a pies between services and we can fetch data between them. Which means, for example, we can make like, 10 more AP eyes and weaken excess every FBI internally and this is really safety out off the box because normally when you just create several projects and for example, you put them in one. Sir, you are communicating between public urals like, for example. Let's say here you're making the request internally, but also with the P address off their server and in here with a special DACA network. We will talk about it in the next lecture. But basically the idea is that nothing outside can ever get data from here. Like from this authentication. Because we're not exposing any ports for outside, which means Onley, our internal docker services can fetch data from one on another. So this is why I like this docker compose approach because it is super secure out of the box. As you can see in this video, we successfully fetched data from other service. So this is how it is done really fast and easy. If you have any comments or questions, feel free to ask them, and I will answer them for sure. 20. Docker network: in this video. I want to talk about DACA networks, but festive fall. Let's check how we can use our FBI inside our else. Indication eBay. So basically, we have exactly the same approach, so we can copy from a pie. This all three pair, Ural and here inside our owls service use innumerable FBI, Ural. And here we don't have hours, but we have a pie and ports 3001 like it was defined here. And just once again, we don't use the sport anymore, because here the sport was on Lee to jump toe this host directly in browser and to check it from our local machine. Now, here inside our hours were oneto uncommon in the sports the last time just to test if everything is working mostly from the browser inside our local machine. So basically, here we have out your l. And now we need to jump inside out and install access like we did previously for a pipe. So basically, the cold will be exactly the same. So let's go here inside the chi and copy paste, for example, this request, basically first of fall in our FBI, we need to create some you request where we can get some data for our authentication service. Basically, it can be that, for example, with current user request we need to send some data Additionally from our FBI, for example. Some I don't know courses or the articles off the user and so on. So let's create here. One more ab get request, and here will be a test a pi data, and we will simply return here our data for our a pine. So rest, Jason. And here, let's say tasty pie data. I don't know. True. And this will be the request that we will fetch inside our authentication service. So let's go now to our syndication service. Very first need to copy this ab GATT because we want to create the same thing outside inside owls. So here in index, as we can see, we have several AB gets already for test for getting a current user. And here will be one more here will be test with current user. Let's rename it test with a pie data. And as you can see here we have all the power. Ural, we don't have it here. But here we need one. You a rebel, and it will be a pair. Your l and we take it from process environment a pie. Ural. Now let's import this property here. So it is a power your l and use it to fetch data. So it is your l. And let's check once again of what a by we have here. So it waas slash and test with not with current user test it I data first. Awful. I forget slash here once again. And secondly, we want to perfect sit here with the pie because we're prefixed in our outside a pie, Ural in environment wearables it also with slash e p I So here is slash e pi slash tested by data. And here, as you can see we're getting this is our authentication service. We're getting data from a player your l and here is test a pi data, and we just have response. So let's name it test a pi data. True. And here's some data from our response. So basically, as you can see here, we have tested parry data. So let's just have one property test a pie datum, But we will ran date from response thought data dot testy p i data. So basically response toe data. This is this object and we just read from their tested by data and return it here. Now let's build once again our docker compose up and check if it's working. So when I jumped to browser, I see the era that access is not defined. Here is local host 3000 tools. So this is our authentication server and this is our request. I just forget here toe import access, so access is require excess. Now we need to start it once again, and hopefully it will work. As you can see. Now we get estate, I data true. And this true is basically a variable from our additional request toe our FBI. So this is our authentication. Get request. So testy power was data. You can see it here, and we're fetching with excess. Some data from our EPA, Ural, and we created this EPA Ural outside in environment where rebels and then will return here . Response data tested by data. So, as you can see, we can simply configure everything so our services can work between them. Now, the question how networks are working in Dhaka at all, so First of all, what I can say for you is that when we just right here some services docker compose auto magically create a network for us, which means by default there is no network there and a docker compose high. It's this and we just get by default that all our services can communicate. And they think this is really nice because you can come inside Dhaka. Environment and Docker compose most mostly because it's just works for you and you can learn later. How so Now the time is coming and we need to learn how it works. So basically, network is new term regarding docker environment that we don't know yet, so we know containers images. Now we know also volumes and new term is network. What does it mean? Network? I think you get it from the name. This is the doc and network inside which our doctor services can communicate and you can configure this network in different ways and it is really efficient. And this is the nice tool that I really like. So basically, first we want to know how we can check what networks do we have. So here we're right in Dhaka Network and we're getting nice help from Dhaka. So, Doctor, network and Command here how we can manage networks so we can connect to contain it to the network and you can get the point. So we're great, faster network and then we connect some services or containers toe this network also can disconnect, inspect and see the least. So let's check the list. As you can see here we have several networks and actually it doesn't say anything from the name in here. This one is quite understandable. The other ones are not so basically riel world DACA default is a network which was magically created for us by docker compose. And as you can see, driver here is breach and we didn't write anything regarding networks. But all our services are in this network and this is why we can communicate between services because they are in the same network. The risk white. A lot of documentation regarding networks in Dhaka composed file and here for us is interesting how we can create our own network and how we can configure them. So basically the default network type is bridge and you can check here, for example bridge and you can see what is it? Almost all my projects I am doing with single network for all my containers and they created eat by hands because in this case it's easier to understand what is it about and what services are in the network. Also that were driver is by me by default in breach moment. So here, instead of the Israel World Doctor default, we can describe our own network. So basically, here at the bottom, where wish have volumes, we can add one new section and it will be networks. And here in networks, we can ride that we have network and let's prefix it with real world Doctor because it will be clear. So we have riel world darkened network and here we can specify that the driver is bridge. This is it. So basically it is exactly the same. What did for us by default Docker compose and you can ask, Why do we need to specify it by ourselves, actually with dawned but for the case that we understand how it is working and we can then simply say what services should be in this network and what should not. We can provide now this network for our services. Now, the question is how to specify what networks do. The chef, for example, in in jinx service. For this, we have property networks and inside we just tried the name. In our case, it will be Riel World Docker Network. And now let's cope with these and add toe each off our services because basically we don't have other networks and it doesn't make any sense for us to create several networks. Yet in more complex projects, we can do it. But we really don't need it in here. So, as you can see, I added networks with our network that were created toe all our services. And now we explicitly Assane, what network do we have here? So this is the standard network, which is bridge. And now when we start it here. So we just missed our docker compose. And as you can see, there is a line created network rail world or cam network with driver bridge. Now, when we write Doctor Network a less here, you can see the name and actually the name is quite bad because, as you can see, we have the name twice here is the rial name off the network. And here with the perfect off EP, We can leave it like this because basically what we see in jahmal file is only this name. And for me, it's much more understandable than the just name network or default network. And basically this name here we really don't see. But as you can see, this is how we can specify networks for our services. So here everything is started. And when were the Lord our application or our a pie? Everything is working like it was previously. If you have any comments or questions, feel free to ask them, and I will answer them for sure. 21. Frontend proxy: In previous video, we talked about networks and made requests from our south service to our APIs service. In this video, I want to talk about front and service and how we can make requests from front and service to our A P I or our house service. You may think that it will work in exactly the same way, like our empire or South. And the answer is no. And this is exactly the problem that they see. And there are lots of questions regarding this approach in Internet. So what's the problem? People are thinking that when they just tried the code like this. So we jumped out front and and here somewhere, we're right in fetch, like we did, for example, inside our FBI. And there, right in here, some guy, your l or FBI house. Ural was excess. It will work. But the point is that it won't. The question is why? Because before we used to ride our beckoned applications, it was written with chalice script also, sure, but it was back and it was known gs here, a pie and south in back and applications. Everything is easy, so you have your back end inside services. You don't have any restrictions off browser because that this is just to services and they can communicate with fetch or with whatever you want and dropped no restrictions with front . And we have a restriction because we're in browser and secondly, So when we're speaking about, for example, Israel world like a calm. This is our host. So this is the machine off the user. So this is is not related in any case, to our docker compose or DACA, it just goes to the port 80 if it's the service. If we're talking about client, he just comes to this year l and for him our website is working. So here is the tricky part. So here, in browser, we can see in sores our javascript that was built here main jazz. Which means this is this javascript that I just opened. And here JavaScript in browser doesn't know anything regarding in Dhaka regarding a docker compose or our doctor network, which means everything that this javascript Nell's is just our host. So the only thing that this code can do is make fetch to some publicly pie in Internet or to make request tothis host this is it. Now the question how we will build our a pie so that it will work. Basically, as I already said, first approach is just here, as I wrote fetch to write their public a pie. So basically, we're exposing our A pie like this and here will be just some AP address, for example. And then we're right in here. Okay, Were fetching. And here is some e p address and then some port like, for example, 3001. And here the request for a pie and polls, for example. It will work, but we're in browser and brother has its limitations. For example, we can't make requests just to any website out of the box. And basically, the limitations are that we can do the requests without problems on Lee on the same domain or sub domain, which means we can't from these domain just simply get requests and get data from the CPI I address because they're not the same. So we have here across origin policies. You can write course inside browser, and here check what is cross origin request means and how it works at whole. But basically, if I will say it insured. This is just super problematic thingy, and we want to avoid using course at any case, because basically, you can configure your service like you're a patisseries, that you will allow some requests from specific services or hosts because we just don't want to make it completely public. But this is streaky and requires time, and you will get lots of box. I saw it in lots of projects, and it was not related to dark a toll. But I am trying to avoid course. If possible, then it will works mostly in all browsers. The question is, what alternatives do we have and the alternative years N jinx. So basically, here we want to jump in our browser. So when we goto this year, L in Jink should understand that we want to show front and service. And then when we right here, a pie pose in gym should understand that we want to get our posts from a pie like we did here. But we won't use local host and exposed port. It will always go through in jinx, which means this is always Port 80 which means it is handled by in Jinx Light Road here in Dhaka compels. So here we're having Jinx, and we have exposed 80 port. So basically, this machine, this is our server. We want to handle it like this. Now, inside our project here, in source app, we can use fetch. But in this case, not for some other host, but for the same host where we have our application, like it should Imperial world. Or could it come, for example, or for development that local FBI posts And it will work without any problems out of the box just because this is the same host? And this is the approach that I like and that I do in all my projects. So the question is, what should we do to configure in jinx for the right redirect. So basically, we want to jump to our engines configuration here. This is the production configuration, and we want to confusion you allocations. So I will just cookie based location here and all FBI requests which ago in with slash FBI . We want first awful toe proxy toe our FBI with Port 3001 and then we want to rewrite them. Basically, if you just write like this, then your request a pie post will just come a like slash posts inside our request inside our service. And we want tohave it without it. I so basically like here in our pay, for example, sores were old, all requests with perfect slash reply. It doesn't. You can of course, do it. But for me, it's look it little bit verbals and basically for thes specific service. When we're looking on it in, isolate, it doesn't make any sense to traffics all your also was a pie. So this is why I want to avoid this. Perfect. So here I'm just writing like slash tested by data and then on the level off in jinx, we're right in the Ural. The question is how we can provide a Ural. So it looks like this. We have specific, specific rightward and then irregular expression. I will write it now and then describe what it does if you don't know how regular expressions works. So basically it's looked like this, and divide means that here register our regular expression. And this symbol star means the start off our Ural, which means here, raise our your l and Slash ap. I should be at the beginning, which means this construction means this is slash a pie. And now here we have this round break its and dot and star. This means that we need this group, which means what in this group is this is the result, which means we don't care about a pie and this will go into result. And here we have this dollar one toe save eat toe property. Basically, you should not understand it full. You can just copy, eat and use relied from Internet if you just go go how to rewrite my your l toe another euro or something like this Or you can just read a little bit about regular expressions. But basically for us is interesting that the Ural when we right here slash e pi slash posts will go to our service as slash posts. This is it. Now I also want to corporate dislocation and to name it alls slash a pie And here I want also to proxy path. But here will be poor 3003 I think. But let's check so heavy tie with sport 3001 and our 3002. So it should be too Now it would work out off the box. So let's check for these we need in our front and to make a request. So let's adhere some button. For example, After Header, we have here button and here on click. So we have on click Handler and here will go our function, For example, make a P I request. Now we need to create this function so here will be const. May keep a request. And here inside, first of all, let's just consul log if it's working. And also I want to install here in front and excess like I did previously. So npm install excess because we also want to make requests with excess. So do you an installation we can already import excels from excess. And now, to make requests, we need to get environment variables. But the problem is that we can't simply give them here like we did for our beckoned applications, because basically, we can arrive them here inside front and part. But they won't just go inside our JavaScript front and build, which means we need to somehow magically give them through our create wrecked app service that we compile toe pass them from beckoned to front, and but we can do much easy approach. We can simply make a request tojust slash and then a pie and, for example, Post because in this case, browser by default will use current Ural. So we're just don't write host and start with slash. So let's do it now here. But the only thing that I want to check First of all, we don't need round brackets and we need here some text like Make a Pie request and then here on the top, we want on click to make this request with excess. And as they said, we just put here slash and then the request. So let's check what we want to fetch. Let's assume we want to fetch something from our pie. So here we have, for example, get who is current user, which is nice to test because in this case we will check if we can from front and make a request o r a p I where we will get a request to our authentication and then get data back in front. And so here let's write like thes And as we said, we need to prefix it with slash repay in other case, our in jinx won't understand. What is it about? So here's a request his a pie, then test with current user and this is get request. Here is our response. And let's simply consul log what is inside response? So just save this. As you see here, we don't have any environment favorables and no host, so let's build it again and check if it's working. As you can see, I don't have any errors. And now, whenever Lord the page in browser, you can see here on the bottom of in you bottom make a pie request. Now we click on this button and we can see in network that we're making the request to the current holes slash ap i slash test with current user and here would get our response. So here the response here the current user information from our A b I authentication service And now from response data, we can access these properties and renders something in our client. So let's check once again how it is working. If we're right here slash sheep I slash for example test with the pi data. Of course, it doesn't work because this is not the correct your l from our EP I hear is test with current user, for example. So as you can see, we can go directly to our FBI service, but only through our domain. Because now we can remove successfully from our docker compose thes sports, for example, here in a pair were already removed them. So we can't just access he pie on its own Onley through our host and the same thing we can do for out because now we're accession them on Lee threw in jinx. So this engines configuration redirect slash a pie requests toe our A pie service and inside they are going result the CPI I perfect. As you see, this is working And now we can also make our request in front and but the most important to remember that front and doesn't know anything about DACA or DACA network because we're running this chalice crypt in the user's machine. So now you foolin know how we can communicate first of all, between services and secondly, between our client code, which is not inside our services. If you have any comments or questions, feel free to ask me and I will answer them for sure 22. Last tuning: we're almost finished Hours A type in off Dr Kam polls before we will check our riel deployment. Actually, it doesn't make that much sense to check the rial deployment because basically, developing in containers is always riel because it doesn't make any difference if you have this container running on your local machine or on your server. But of course, I will show you how this containers ah, working in production so you can see that it's exactly the same, like on my own machine. But first of all, let's do some find union to check that everything is working as expected for development, environment and production first Awful. Let's remove ports from here. As I already said, we don't want to expose any ports because we don't implement public ik I for now, all our ports I exposed Onley through in jinx. So basically on Li Jing's is exposed in 80 port and then inside engines configuration Here we're proxim toe the pores but these are internal ports off Dhaka network. The next point used to remove environment variables that we don't use. So basically, this host here inside FBI and this host here inside authentication is not used, but actually I want to describe the use case when we need it. So let's assume that at some point you want to redirect a user to your aerial host, for example, your inside FBI and basically the result off the response is not the Jason, for example, but every direct to the home page, it certainly can happen. And then you want to know what host you need to redirect. So basically you're writing inside You're a pie in source something here. No tres Jason, but dress redirect, and here should be a your L. But the point is that our A pie serious is stateless. It doesn't know anything regarding your URLs or what Host of Iran In our application on for these, we need to provide environment variables and this is exactly the case. So basically, I will remove it for now. But at least if you need to implement it, you know why you need it and how you can handle it. One more point is that foreign Jing's here. If we do in in jinx this proxy in for a pie and here actually this is copy paste here we should put hours and not a byword. So basically we're doing here three proxy in and to do it correctly, we need here to write more Depends on. So basically, we want first to start this 33 services and then we're sure that are in jinx. Will proxy request correctly and we won't get a narrow. I think that our configuration here is looking really nice. So we wrote here everything that we need and we now need to check if our docker compose development is also sufficient. Actually, it's not because here we described on the front and Andy Pie. So on the left is our production configuration on the right eye open development. So here for front and everything is looking fine. So in Cam Rahn start is the command that will start the web. Serra off. Create react. Yep, these two things were needing for exactly create raked at and here we have front and sores . This is our volume, so we can change file and our service will be automatically re started. Now let's talk about a guy first. Let's check if we have this command. So here in Peca Jason, we have start for production and there for development and this is no demon. So this is exactly correctly and hear All source files are mounted toe volume. We also want to do the same thing in regard in our house. So basically we have all service and let's check if we have this command inside. So here we also have deaf for no demon. So here in PM, rondel is fine and volume is the same. So here will be not a guy but our source and here, user source AP source. So it all looks fine here and the last thing is engines so in in jinx we want over toe override Onley these configuration here, As you can see for production, we have here in Jinx Khan fraud and for development. We want tohave in Jinx Khan death or local whatever you prefer. So basically I like to separate these two convicts completely. Basically, it is possible to create just one conflict and then toe pass inside invariable environment variables. But I think that it is much more difficult to support and to check because if you have this strange in jinx template with environment variable sense on. So this is why I always just create toe conflicts and this is exactly what I will do here. So we have engine exports are staying the same, which is NATO over right. Our volumes basically can copy this line completely because it the same and here instead of broad, I will write, for example, death. So death for development and the path will be the same. Now let's check that our development DACA is working. So we just tried Docker compose minus f docker compose jahmal mindset Docker compose development up build and we're checking if it's working. Actually, I got a narrow because my website just stopped working And the point is that here for engines, I didn't copy the conflict foreign jinx called prod. So I just want to copy and paste here it with the name in Jinx Khan deaf And here. What do we need to change? So basically everything exactly stays the same. So this proxy in is the same like in production. So here, the only thing to change its server name from real world DACA dot com to local Basically, nothing says against to use the same domain as you're using for production on loco in just update your hosts file, but I think it's more convenient to distinguish between two Urals. This is why I am copy pasting everything. And here I have local. And if you ask how we can open now this your l you just need to open host file on your machine and paste this domain here like we did previously. So basically I am just type in the domain and restart Waas Once again my doctor composed And then when we jumped a real world dark adat loco, it should open our your l As you can see, we can jump to local hasta que loco and actually it is working but he ever get an arrow with web sockets. So basically several words about the sockets. So by default, create react app is having this future which is called Holter Lord, in where Between the sockets threes of obsequious connection for Yoko great wrecked Apple observer. And this means that every time when you save the file threw up sockets create wrecked Every observer is getting the response. A K file was changed and then the page will be relied. The point is, here that our in jinx and this is actually in jinx. Now, what is serving this Web server with this proxy pas that you saw here? And this in jinx by default does not support with circuits. This is why we're getting 404 And we need to configure this location properly and we can do it. We need to upgrade our http version. So basically, hereafter proxy parts, we can just try it, for example needed for sockets. Just understand why resulted here. So it is. Proxy. Http version It could be 1.1 and then proxy said header and here header would be Upgrade dollar http upgrade. And then the last one is proxies had header the same connection and here raise, upgrade stream. So basically, in this case, we're saying foreign jinx to use http version 1.1 and here is special upgrade headers. And now, when we start our docker compose and reload the page in browser, you can see that we don't have an era with web sockets and weaken jump in network and here field with bob sockets and you can see the socket connection on real world Doctor Loco, and it is fine. So this is get with 101. So everything is working as expected. And let's try, for example, to change one file like here in front and let's name eat Web circuits fix and we just save it. And as you can see in process, the page was real. I did, and we get this message website gets fixed. The last thing that I want toe change is that in our development mold when were built in front and in Dhaka file, we have npm run build and in PM install serve. And you could see that when we're running a development build, we're making this production build and basically in development. We don't need thes two lines, so it is possible t just use different doctor files for production and for development. So for this I want to write here prod So basically in the same way like with it findings there is proud and three staff. So here is broad and I will just copy this file and paste and rename it toe docket file death and basically I want just in Dhaka file death to remove last two lions. So basically we're equipping on all files and PM in style. We need but we don't need in PM Ron build and in PM install serve our profile I am living the same like it Waas Now we need to make an adjustment here inside front and in development jahmal and in production. So basically here as you see a way said build and build is front and folder. This means that the doctor will just read doc file from thes built folder and it expects to have DACA file with the name docket file there, which means our name and DACA file Prod and Docker file Dev won't be read it because it's not default. And basically here we can remove this line and say two things First of fall docket file and this is the name what we expect. So in our case it will be docker file prod and the next thing is context. So context should be front. And the idea is that context is just the working directory where we will look for DACA file here, which means here the context is front and this is why we don't need to perfect our path for docker file here. Now let's do the same for development as you can see here we don't have built parameter at all. So here I want to specify build and over, right dog, A file with DACA filed or death. And here contexts is front. And so basically this is it. In this case for production development, we will still build our project and install n g serve. Sorry, just serve is too deeply serve. But for development we don't need this and as you can see it now I restart. Docker compose. And as you can see this front it will be much faster because we just install packages. But we don't need to build the whole project and to install additional package after starting Docker compose, you can see that everything is working in the same way as previously. So basically our configuration for Dr Composed in production and in development is fully finished. Now, just to check here we have this bottom may keep a request and as you can see, it is still working. So here we're getting the data. And in network, when we filter for X, each are you can see that we're making a request for the current dough male slash eight i slash test was current user. So this means that everything is working mostly and we can go to deploy our project to production. If you have any comments or questions, feel free to ask them and I will answer them for sure. 23. Do it yourself. Mailer: in this video, I want you to try an implement one service by yourself. Previously, we did all services together, but I think it's a nice possibility to try and implement one part without my guidance. So if you want to do it, just watch reader. If not, you can just keep this video and go directly to deployment videos. So here is the task we talked about Heaven Mailer service. So, basically, what is Mehlis service? It's a service which has some A pie, and you can from your different services. Ask this a pie to send an email, for example. Let's say we are on front and and we have here form to register user, which means we have a request from front and to our authentication service, where we're saying OK, Police registered this user in the case that authentication was successful out. Syndication service should send any pie coal to our Mehlis hurries so that we will send an email. So basically Mehlis services really scoped. There is no database there, so we just say the body and the title off the email, which means something like okay, user was registered. This is the name and this is an email and then in male, have maybe templates or whatever you want to send an email. And basically this is like isolated scope Tinky, which wraps some third party mailer application or sauce that you're using, and just for our application. It simplifies with this working with third party library. So once again, the goal is just implement new service where you will have any pie. You can just make several test coals like, for example, send registered email or sand ist successful email off for subscription or notification, and just try to communicate between different services. You also need to describe the service for production and for development, so it should have volume, and you can then change your files locally and see that project end Web server updating. So I think this is a nice, small task to try, implement and service yourself. If you have any comments or questions, feel free to ask them, and I will answer them for sure. 24. Pushing to git: in this video, I want to start part regarding deployment. And the first question how can we deploy everything that we did to production? And basically, with DACA, there are like millions off tools to deploy to production. Some of them are three. Some of them are paid off course, I prefer three and stable. This is why we will stick with Docker, compose and get basically the idea with DACA and Dr Hub by default is a little bit different than I am doing it. So basically, when we're going toe a dock, her hub and we're open a website the idea is that you can register here and push your images. Which means at the moment when we used images like you saw here, for example, we used image foreign jinx among go it waas that somebody pushed the image toe the doctor hub and then we can pull it. This is all fine, But when you see pricing, you understand that there is some hidden thing is which basically means you can't simply push any amount off images that you want. You need to pay off course. There is like community for public rappers, but who wants to push private images even for testing inside duck hub and bay money if you want them private, which means we need some are the solution Actually, the idea with DACA hub and with push and pull in the image is Israel is strong and nice. Which means just imagine that I rented the server and now I want this project to be available there. So basically, if I push of this images that I created so basically here we created, like, five images for every container of every service in Dhaka hub and then I can simply pull this images once and use them. The idea is that I should not build them as you saw here, what we did every time we build them every time when we're running up. And this build process is really long. But basically, from my point of view, it does not make any sense to use DACA Harb Oh, are other different solution where you need to pay money just because your image will be pro build there. We can simply build this image directly in the production server. And nothing says against these because basically, it's not like you have 2000 servers and building the image in every service is that difficult? So basically here is my idea that I'm using for all my project and not only mine, but also company projects. It is working really nice And you don't need DACA hub or similar solution for this. So we simply put our cold as always in get rapper So we did it for all projects. So you have get hub, get lab or whatever you want, where you host your get trippers. So we're just pushing their cold. Nothing more. No images, no doctor, nothing. Then we just configure a server like some normal Lennox server from any provider whatever you want. And there we install DACA and Docker compose and, of course, get then we simply need to pull our project from get triple. And there is always Iran docker compose build and afterwards Docker compose up and basically we're ready. No specific tools. Just get DACA and docker compose. Obviously, if you're doing such things for 200 service, it doesn't feed but normally if you develop in small projects and leaving not that small but for small teams like 10 15 people, you still can use this approach. It is really not time consuming and you don't need to pay for anything. So this is how we will deploy with our project. So for me, I am a get lab user. And here if you want to push our project to for example get lamp or get have or what you have you simply need to create a new project. It is like the same interface in every platform. So here is the project name I can use Real world Dock him. I think this is name already used by me because I already pushed it. So I will create real world aka test And here it is private. So this is why I like it. Love you have private Reppas for free And here you have instructions how you can push, for example and exists unfolding. So this is exactly what we have. You need to have Giddens teldyn your machine. I hope you have it. You can check it with G minus minus version. Then you simply need to write getting need, then get remote at Origen. And this is the Ural off my rep. Oh, Then get add. You'd commit and get push. And after these this is exactly I did this because I saved all files that we have. So I already have this rapper. And here is my push Trapper. So this is just all files that we have here. And if I'm just a jump into the branch, where am I? You can see all our before olders that we created And two things Docker compose development and docker compose. Yeah, mo So everything is pushed and now we can start with production server. If you have any comments or questions, feel free to ask them and I will answer them for sure. 25. Setting up production server: in this video. I want to talk about setting our production server basically to run our code and our observer somewhere, we need to rent a server and pay money off course. I understand that for the purpose off just completing the course. You maybe don't want toe pay for the rial server and to spend money for these. So basically festival. You can just watch the end of the course without paying the money for the server because you will see that it is working just like this. And you can do it when you are ready for this. And secondly, you just need any Linux machine where you will start the doctor with docker compose so it doesn't need to be a rented server where you pay mining, you can simply install your Linux machine. Just any Lennox that you want to test. For example, on your old machine or on your current machine. I will use their prices solution. So this is what I'm using myself. But this is not an advertisement, so you can use whatever cloud service you need. So basically, we just need linen service with a sage, and I'm using heads in a because it's really cheap, and I think this is the cheapest thing that I found it. So here you can jump to cloud and here you have prices. And basically the cheaper server per month costs around three euros for two gigabytes from and 20 gigabytes disk space. So I will create here than your server just for the testing purposes and then remove it when I don't need it. So basically here I registered as, ah user. And here you can just click at server and then you can select the allocation. Actually, doesn't matter. Image will use who won't toe 18. It's fine types tendered. It's also fine. And here you can check the size. So basically I will take the smallest and here on the right, you can see that price is almost three years per month. Basically, you don't need anything more expensive. This is enough for even several projects. So this is it. Basically, we don't need volumes. We don't need network. We don't need additional futures. And actually nothing here I will write Docker. What was the name Doc? Real World took him. Soldier. Let's name Israel world dot com, and I think it's nice name and no ssh key. Selected very command to use an ssh key. Actually, this course is not about Lennox and how to set up securely knocks era. So I will just say that if you want to do it properly, you needed Lee some knowledge like that you should not use a root user. For a za normal user on your server, you need at least to create additional user and give this user sort of permissions so not fully route. And in this course, just for the sake off simplicity, I will use exactly the route user by default of the root user will be created. So we will get a passport by email and we will simply install DACA and Docker compose So no riel server configuration that you really need for production. So here I just click create and by now and then it is created. You can see here process and on email I will get their credentials for my root account. So basically I already got an email with the passport for the root account. So here is I just clicked here in this new server and as you see, we have a p address on the top. So we need to copy these and then just based It's a sage route. And then at and the CPI address. After this, we should enter, and we need to provide route passport from the email. So here I pasted the password and we need to provide current password and then you password because the password should be automatically changed to your password after you get the excess toe the server. So basically here, a current password and then you password. Just try something secure. And now we're inside our shell. So here, as you can see, I'm in root directory and I'm here in my rented Sarah. So now all looks good and we need to install DACA and docker compose. So here in Hesse, the reason eyes article already how to install DACA and how to deploy Known she s application, it is super roar but apart regarding insulation DACA and docker compose is really valid. So I used this link. This is like a community documentation for heads Now if you don't like this tutorial, you can take whatever tutorial you want. The main idea is that on your system, you need to install DACA End, aka Composed. So here I will skip part with configuring image and so on and pushing toe hub. This is exactly what we didn't do. And here is the step for in style in Dhaka on a bundle. So first of all, we want to update everything and then to install these packages that are state here. So we just based everything and wait. So looks like like everything was installed. Now we jump on the next step we need to add DACA gp geeky and configure custom Rep. Oh, So basically, we can simply copy paste these again in the common line and here it is installed. The last step is to make an update again because we need to update this custom app triple and then install joke isi. So I just based this commands and again we need to wait for installation. So here we're hitting. Yes, and DACA is being downloaded. Now you can drive dr minus minus fashion and check that doctor was successfully installed. The next step Eastern style DACA composed and basically the rot took a month's here, The 1st 1 don't lords a binary and the second said this binary to be allowed to execution. Now let's check if we should have Docker compose so he had, like a composed minus minus passion. It is also the installed and available and the last step is to add our current user here toe DACA group. So basically that we can John doctor commands from our current user. So we simply need to paste this command. And as you can see, my user does not exist. And I hope that for security reasons you will create not root user. But you're only user. But as this is a testing process, I will simply right here route using. But of course, it's not good to use root user at all. It should be only for admin privileges. Now let's try to run some doctor command so we can ride Dr Processes and see that we don't have any processes and everything is installed. Which means Doc is there. Docker compose is there and we spend, I think, less than five minutes to don't lord everything on our new server. If you have any comments or questions, feel free to ask them and I will answer them for sure 26. Deploying project: In previous video we successfully configured our server. So DACA and Docker compose is available farce And now we just need to deploy our project. So basically it's really simple. First awful. We want to clone from get lab our report. And secondly, we just want to do the same commands like the did locally. So here I go to my ripple and take the branch that I want. If you have master, you just take master. And then here is clone and we want toe klik Copy here l from clone with a sage. So here we're right in Git Clone. We can simply copy it toe our root folder. Or we can create here, for example, Projects folder and here inside project. We want to get clone our get lab real world. So as you can see, git command not found Which means that they need to install get so apt Get install get Let's try again Get clone And we're cloning our real world. Okay, And here we need to hit. Yes, because we're doing it the first time and we don't have access to the report because obviously this private ripper and excess denied. So we need here a public key to be able to clone the repo. So here we need to create an ssh key on our server. Get a public key and put it inside. Get lab. And for this you can simply Google get permission denied public key on Get lamp on something like that. Basically, the idea is that you simply around as a sage again and it will generate a keep your prayer between public and private every Saiki. So it will be safe toe dot ssh idea air. Say, you just need to hit Enter one more time enter because we don't want a pass phrase And now it waas generated. So here we can do a less. For example route that's a sage. And here we have our keys idea, Risa and ideas up, up now you simply can open with them. I d s a pub. So it iss slash ruled daughter s a sage i d ERISA pump and the team is not correct. Commander told BV and as you can see here you have these key So basically you can simply copy everything and young it And now go toe our get lamp configuration in your profile. So basically, in your profile, you can click on settings. So here is settings and here you have Ssh key. Now we're simply paste here the key and click at key. After you did thesis, it should work with pulling our rep. Oh, so let's try again here with have Git clone. And as you can see now, we don't have any problems on Clone in the rep. Oh, so here I have real world. Okay, let's jump into the folder. And here you can see get remote mine expression. You can see that it was pulled from Get lab. Now, here I am in real world took a folder and we want to start Docker compose build. So we just tried Docker compose build And this is it. We don't need minus f here because we simply do a production build. And as you can see here we have some images and some images will be pulled. So basically, after this, we're doing all the same stuff that we did in our local machine. And as in our local machine, we developed with Linux images, it is everything isolated and it will 100% work, So it's not like normally, Winds told previously result Dockers some tools locally and then on production. They didn't work here. It can't happen because every time when we create a container we start with the super fresh container with the same image. But here is one more important thing to understand. There is a difference between building an image on production and pulling the image from Dhaka hub. So basically, you can feel the difference when we're building something on production. We can't be 100% sure that it works because we're building it from our files. Which means that, for example, here somewhere we had mongo latest. So here we don't have specific version, which means when we're building on production manga latest, maybe we will get the latest version which won't work with our project. So either you need here specific versions like we did here with known jazz as you remember here in a pie, for example, with specified exact version. In this case it will be built the same. But of course you should be aware off it. So this is why I try always not to use things like latest or stable, but change them later in exact version. As you can see here after dark, you compose build everything was installed and dull images were created. Now we simply need to run Docker compose up and this is it. This is exactly what we did on our local machine. Now, as you can see, a docker compose up was successfully done on our server. Now the question is how we can open a re a world aka Com on our server. And normally we can buy the domain, for example, this one and then in original registration, you simply set the configuration off the I P address which will be bind it with this domain . We don't want to buy a domain and do this process. So the easy answer is the same, like we did previously through the host. So basically, coast is really nice thing because you can say on your local machine that you don't want to go to the Internet and look for this domain. But you simply want toe Hecate. And in this case here, we can provide for rail World that could that come? Not our local host, but e P. Address off our server. So here I copy from the console heads. Now that calm cloud the AP address of my server and paste it here and now with Israel World docket had come When I will open it in browser, it will jump tothis ap address and not in the rial domain if it even exists. So let's hit here. Enter And as you can see in the console, I will just make it clean once again as you see our docker compose up Israel in inside our server. And these are logs from our engines, which means our domain already works from our Sarah. So basically, unless than two minutes, I think, or at least two commands we started on production fully our project without any big hustle because we're 100% sure that our project will work on any machine. As you can see with just Ron Docker compose, build Docker compose up and this is it is you can see now I relied the page and it doesn't work because I stopped the process. Now the main thing here is that you don't want tohave it handling in console like nonstop a ble You wanted to be detached from the console and for this. You have dug a composed up minus D command. And as you can see here, we're starting everything. But you won't see the logs afterwards because it will be detached. So now, as you can see, our consul is free. We can clear eat, and with docker processes, we can check what processes do we have? So these are our processes for real world doc A pie. And if you want to check logs, you can write darkened logs and then the name, for example Logs from in jinx here will show in genetics locks And now with the Lord again . And as you can see, our website is working and this is exactly how I deploy projects to production. Just get clone or lay to get pool. And then I just Iran Docker compose ar minus minus build. And then if it is needed, it will be automatically built ID and it around again. And now you can even check here in console Ive Our empire requests between services is working. So you can see that Yes, it is working because here we have real world rocketed calm and hear our response and it is working. But here we're using our production domain. So basically, this is how easy and nice you can deploy Docker Compose applications to production result any Hessel. If you have any comments or questions, feel free to ask them and I will answer them for sure. 27. Cleaning docker: In previous video, we successfully deployed our application to production. Now I want to talk a little bit about cleaning. So basically you and after we implemented this project, if we will write something like Docker Image, for example, dark image, unless you can see quite a lot of images on my machine. And maybe even some images are not what we installed. So basically here, as you can see, I have lots off images, non non, and this is also a problem. So first off, all the question is what is known non and how we can remove everything safely that we don't need. So none non is normally some immediate intermediate images that we don't need, but they were used for building. We don't need to get deep inside this teeny, but we want to for sure delete all images that are not used. The same thing is regarded containers that can be started on our machine or just hangs there networks, volumes or whatever, Doc, you things you created so normally a long time people were removing thistle images by hands , but now there is a really nice command. If you write DACA system and then he enter, You see some system things that you can use and there is a special command which is called prune, and it removed and used data indeed can clean safely Everything. What I mentioned, like images for Williams containers at so on. So let's try this DACA system prune And here we're hitting Enter. As you can see, this will removed all stop containers all networks which are not used by containers, all dangling images and all cash. Which means basically, if we don't have run in Dhaka comm polls like all this stuff will be removed. And this is all fine because when we build it our images, we can just make up command and we will use them. So basically it is fine to remove here everything and no, this command wont break your system. So basically I'm just hitting. Yes, and now it will be removing things and sometimes it can clean really a lot. Sometimes it's not that much, but here you can see that it deletes containers and it deletes networks. Basically, here you can see that some networks like the default one. It's still there because it was created a to the beginning for our real world. OK, but then we switch toe named network and this is why we don't need it anymore. The same is with images. As you can see, it takes a little bit of time, but at the end we will see how much in dilated as you can see, it took like, two minutes on my machine to remove everything, and the most important part is deleted images. As you can see, I had quite a lot of them and at the bottom you can see the total removed space waas six gigabyte. So I recommend you to do this procedure from time to time on your production server and also locally when you develop, because in this case you will reclaim a lot of space. If you have any comments or questions, feel free to ask them and I will answer them for sure. 28. Homework: So here, where you successfully finished my cars off Docker compose and Dhaka and were successfully deployed our riel application to production. I think he understood the doctor is not a silver bullet but it is a tool which was really nice road and we can use it really efficient four local and production development. So yes, it happened. Doc Files and Docker compose can be tricky, especially with such things like foot mantra, Lord and so on. But basically we're doing it on the ones after the's developing locally and deploying to production is really nice and fast. And of course, the most important is that it is stable. Now the question is what to do next. And of course, as always, I'm saying that learning through the course is nice Doing really, Application is good, but doing it by yourself is most important. So basically, I recommend you to take a project. If you already have, for example, some small side project and try to write it with DACA and docker compose just for the sake that you understand how it works from start to the end. If you don't have such project than just take any project that you want to develop by yourself. For example, I don't know you want to build any pie for cinema or maybe a clone off Netflix, or maybe a trailer dashboard and just write implemented from scratch using Docker and is always if you have any comments or questions, feel free to ask them, and I will answer them for sure and see you in my next course.