-: In the last section, we pushed off our project
to Travis CI, or more precisely GitHub.
Travis CI picked up the project and started building it.
So my project finished building,
all the tests ran successfully,
and you can see down here it says preparing deploy,
and then deploying application, and then eventually done.
If you now very quickly go over to your Docker dashboard
and refresh the page,
really important, make sure you do the refresh
because it won't always kick in
the updates here automatically.
You might see these spinners that say,
"Oh hey, we're doing a deploy for you."
So the reason that I'm showing you
this kind of spinner right here
before the deploy actually finishes up,
is that when this finishes
there's actually gonna be a little bit of an issue.
We're gonna see that after deploy completes successfully
if we try navigating to our URL,
the page is just not going to load up.
So let me tell you about what's going on.
If you recall, every time that we've ran a web server
inside of a Docker container,
we've had to do something like docker run -p,
and then we did that port mapping
and then specified the container
or whatever it might have been.
So the port mapping right there is done
because by default no port inside of the container
gets exposed to the outside world,
we have to very directly set up that port mapping ourselves.
Now you might notice that everything
that we just did with Elastic Beanstalk,
at no point in time did any of this port mapping occur.
So it's a step that we just kind of
completely neglected to take care of.
The reason that we didn't take care of it right away
is that if you went through all the documentation
on Elastic Beanstalk around Docker,
well they're gonna be, they're not gonna quite
throw this little tip out there at you.
You know, they're not gonna really say,
"Oh yeah, you need to expose the port",
because when we expose the port on Elastic Beanstalk
the process is just a little bit different
than the command line that we've been doing so far.
So to expose a port with Elastic Beanstalk,
here's what we do.
We're gonna find our dockerfile
that is used for production deployments,
and then inside of here, right after the "FROM nginx",
we're going to say EXPOSE 80, like so.
The EXPOSE instruction is something
that we have not used before.
In a development environment,
and actually in most environments,
the EXPOSE instruction is really supposed to be
communication to you and I as developers.
This is really something for you and I
to read inside of a dockerfile and understand,
"Oh, this container probably needs
"to get a port mapped to Port 80."
So by default on our machines,
like your laptop and my laptop,
just putting in this instruction
does absolutely nothing for us automatically.
Now, AWS Elastic Beanstalk is just a little bit different.
Elastic Beanstalk, when it starts up your Docker container,
it's gonna look at this dockerfile
and it's gonna look for the EXPOSE instruction,
and then whatever port you list in there
is what Elastic Beanstalk
is going to map directly, automatically.
So again, for you and me,
just putting EXPOSE in here does automatically nothing.
Elastic Beanstalk is different in that regard,
it's going to look at this EXPOSE instruction
and use that as the port
that gets mapped for incoming traffic.
So I'm gonna save this,
and again I wanted you to see this ahead of time
because I didn't want you to like,
and as a matter of fact you'll see right here
it says degraded.
Chances are it'll say something like,
"Sorry, but I wasn't able to actually start up
"or anything like that."
Probably somewhere in there.
Well, somewhere in there, it'll be there
but you get the idea.
It definitely is not working
quite the way we expect right now.
So we're going to make that change,
I got the EXPOSE 80 there.
I'm gonna save the file.
We're gonna do another git commit,
another push up to master and let everything deploy again.
So back in my terminal, I'll do a git add,
I'll do a git commit, I'll say added EXPOSE 80,
and I'll do a git push origin master,
and we're gonna let this thing
redeploy itself all over again.
So another quick break and I'll see you in just a minute.