All right, so now that we've learned about pushing our images over to Docker Hub, I already went ahead
and pushed each of these images.
So I started off by building each image, uh, starting off with my username, the one that I use to
log in to Docker Hub.
Also, make sure that you're signed in.
All right, followed by the image name, uh, the image repo in this case, and the image version,
which is going to be 1.0.0 for each one.
So order management, product catalog, uh inventory support team shipping and handling, profile management
I tagged all of these images as 1.0.0 pushed them to Docker Hub.
The only one I didn't tag as 1.0.0 was the e-commerce UI, because this application is not going to
change between section three and section five, it's going to remain the same.
Uh, but the other applications will change.
That's why we're tagging them with semantic versioning.
So go ahead and do that.
Uh, push all of these images over to Docker Hub.
Okay.
For e-commerce UI, you should only have one image tag of latest whereby whoever needs to create a container
from this image or whoever needs to pull this image can just use the following command.
And then once you have that pushed, copy the readme, uh inside of your course resources into the repository.
Overview.
This informs whoever needs to create a container out of this image.
How to do it properly.
Uh, what the application, what the e-commerce UI app relies on in order to run.
So the six different API's running in six different containers, as well as the environment variables
that it relies on in order to connect to the applications running inside of these containers, so on
and so forth.
So the e-commerce UI should have one tag.
Uh, every other microservice should have a tag of 1.0.0.
So the e-commerce UI has a tag of latest.
All of these should have tags of 1.0.0 for now okay.
We're not going to give them the latest tag yet.
So that's it.
Now what I want to do, uh, before we move on to the next section, is go over to images and delete
everything, because going forward we're going to start grabbing stuff from Docker Hub.
Not all of them were deleted.
That's fine.
We'll delete the containers Tanner's first.
Now delete the rest of the images because there were some containers that were lying on them.
That's why I didn't delete no volumes.
And now that we've deleted everything, I'm going to say Docker system prune dash A just to make sure
that it deletes everything else.
And it deleted the network that we created.
All right.
Now we're ready to move on to the Docker compose section.
All right.
So let's set up our Docker compose file.
I still have every single command that we use to set up each container.
So what I'm going to do is copy these commands over to my docker compose YAML file.
So that's the command for the profile management service.
That's the command for the wow for the e-commerce UI service.
It's a long one.
Let me copy the one that I have over to Docker Hub, because I also added formatting into that command,
which should make it easier to look at.
All right.
E-commerce UI shipping and handling.
Because basically in your Docker compose YAML, instead of creating the containers inside of your shell
using the docker run command, you can create the container configuration inside of Docker-compose.yaml,
just called Docker compose up.
When you need to create the containers and docker compose down when you need to destroy them.
Making things very easy to manage.
Copying this over the product catalog.
The order management.
All right, so what should we start setting up first?
How about the hardest one, the e-commerce UI?
Well, we got to start with the e-commerce UI anyways because that's the UI.
So um, version three, the services, the first service is going to be the e-commerce UI.
So right here we're declaring that we're going to create a container named e-commerce UI.
The image from which we're going to create the e-commerce UI container is going to be our slim 087 slash
e-commerce UI.
All right.
The one I pushed on to Docker Hub.
Make sure to use the image that you pushed.
I'm pretty sure my repo is public, so you might be able to use mine.
But anyways, the container name we're going to specify as e-commerce UI.
By default it should have this name, but I want to explicitly specify a container name as well.
Ports.
We don't actually need to do any port mapping, but anyway, let's just be consistent with our command.
And now the application relies on environment variables in order to run there.
Let's just copy every single environment variable that we have here.
So react app profile API host.
Set that equal to that.
I'm just going to copy this.
Five six.
Product API host.
Product catalog.
Product inventory.
React order API host.
Order management.
Shipping API.
Host shipping and handling.
Contact API.
Host.
Contact.
Support team.
All right, that's all.
That's all we need to do.
And now what I want to do for the sake of practice is have, is to make sure that this e-commerce UI
runs last.
I can do this by specifying what this container depends on in order to run properly.
It depends on the profile management container starting up first.
It depends on a bunch of other containers.
Product catalog.
We haven't defined those containers yet, but rest assured they will have these names.
Product inventory.
I'll be very surprised if by the end of this I don't make any like typos or anything.
We'll see.
Order.
Management.
Shipping and handling.
Contact support team.
So because the e-commerce UI container depends on all of these containers being started up first, it's
not going to start up until all of these have launched before it.
So it depends on allows you to dictate the order in which containers are started up.
All right.
So we're done with the first service.
The next one we can do is profile management.
All right.
So the next container is going to be called profile management.
Uh with the YAML.
Indentation is really really important.
So make sure to specify the profile management container at the same level as the e-commerce UI container.
All right.
Whereby anything below anything after the tab Belongs to profile management.
So this container is going to be created from the image are slim 087 excuse me slash profile management
10.0.0 knows is getting really itchy.
Container name profile management.
We got to be consistent with what we have here because the e-commerce UI container depends on the creation
of this container before it can start up, uh, ports.
Um 3003 what was the port mapping?
33033303
okay, that one doesn't rely on any environment variables.
All right.
The next one we got to create is product catalog.
That container is going to be created from the image our slim 087 Again, make sure to use your username.
Um, product catalog 1.0.0.
Um, container name product catalog.
Staying consistent with what we have here, just copy it just to make sure ports ports is going to be.
Uh 30013301
okay.
The next one is going to be, um, product inventory.
The container will be created from the image are slim 087 slash product inventory 0.0.
Container name.
Um.
Product inventory.
Ports going to be.
30023002.
All right.
Next container.
Is going to be, um, the product support team.
No contact support team.
Which will be created from the image.
Is this right?
Oh, too much spacing again.
Uh, make sure that your spacing is consistent.
It matters a lot when creating YAML files.
YAML configurations this will be created from the image are slim 087 slash Contact Support Team version
1.0.0.
Container name.
Contact support team.
Make sure it's consistent with what we have here.
So this is a good practice because if the container for some reason doesn't exist or you forgot to define
it, this will throw an error because the e-commerce UI depends on that container being present within
the same Docker compose network, within the same docker compose environment.
So that's the image container name ports uh 8008 thousand.
We don't need to do container mapping because, uh, the e-commerce UI is going to connect to it directly
within the same network.
Uh, the port mapping is more so for us if we decide to troubleshoot the app by accessing its endpoints
from the browser.
Lastly, we are going to set up the order management.
Um service, whose image will be, uh, derived from pulled from Docker Hub R slim 087 order management
1.0.0.
Container name will be order management ports.
That's going to be 9090.
All right.
And the order management microservice relies on three environment variables in order to run uh so environment
product inventory API host.
We set that equal to HTTP product inventory.
All right.
Uh product catalog API host.
We set that equal to HTTP product catalog shipping and handling API host.
We set that equal to.
Shipping and handling.
Ensuring that these match the container names.
All right.
Um, I hope I didn't make any mistakes.
Let's try this out.
We don't need any of these.
Uh.
Whatever.
I'll start it up again later.
Uh, CD we're going to go to.
Workbook starter projects.
Oh, for starter projects.
Then I'm just going to say docker compose up.
Service ecommerce UI depends on undefined service shipping and handling.
Cool.
So I must have missed one of them.
Shipping and handling.
Is that what we call the container?
Oh, I totally missed the shipping and handling microservice.
So shipping and handling.
Let me go to Docker Hub because I forgot what the image name for that one was.
Oh, just shipping and handling.
Cool.
I knew I was missing something.
These things never just work from the beginning.
Uh, we'll call the container shipping and handling.
Here you can see the Order management API is trying to connect to the application running inside the
shipping and handling container.
or that will be running inside of that container ports.
What port is it using?
Let's just go into the code itself.
80.
Docker compose up.
All right.
It's pulling all the images from Docker Hub.
All right.
It seems like everything is up and running.
We'll go to localhost 4000.
Um, product catalog.
We'll try to order something.
Everything works nicely.
Order.
Management.
Place.
Order.
All right.
Um, this might not work because you need to sign out and sign back in, but whatever.
I don't feel like doing that.
And, uh, that's it for Docker compose.
So all we did was we basically rewrote all of these commands as configurations in a YAML file.
That's all.
But the beauty about this is that now I can just create another terminal and say docker compose down
up another terminal and go into the appropriate directory workbook starter projects oh three Starter
projects oh four Starter projects And say docker compose down.
So that's going to stop all of my containers.
And after it does that's it.
I'm just going to make sure I go here.
Got no running containers.
I've got all of these images that were pulled from Docker Hub.
I'm going to delete them.
Deletion failed.
Nope.
It did not fail.
And perfect.
That's all for this section.
In the next section we're going to connect most of these most of these applications to some sort of
database.
And we're going to update our images and push them over to Docker Hub.
See you there.