In the last section, we spoke about how it's probably going to make sense to have two different Docker
files.
One Docker file will be responsible for running our application development, the other in production.
In this section we're going to start working on the Docker file that is going to run our application
in development.
So let's get to it.
I'm going to flip back over to my terminal.
And I'm going to open up my code editor inside of our project directory.
Inside of this project folder I'm going to create a new Docker file.
But I'm going to give it a name slightly different than the name that we've seen before.
I'm going to create a file called Docker file.dev.
The purpose of the.dev on the end right there is going to make sure that it's really clear that this
Docker file is only used when we are trying to run our application in a development environment.
In the future, we're going to put together a second Docker file for running this thing in production,
and it's going to have a name of simply docker file.
So that Docker file that is named simply Docker file will be the one that we use for production.
Otherwise, if we're running locally and we're trying to actively develop our application, we'll build
our image and we'll start up our container using the dockerfile.dev file instead.
So inside of the dockerfile.dev file, we're going to write out a little bit of different configuration
to create an image very similar to some that we've made use of before.
We're going to first start with a base image.
So I'll say from node colon alpine.
We'll then set up a working directory.
So I'll say Workdir of app.
We'll then copy over our package.json.
So I will copy package.json to the current working directory of slash app.
And then we will run the command npm install.
After we install all all of our dependencies we'll then copy over everything else from our project directory.
So I'll say copy dot dot.
And then finally we can run our command to start up our project with cmd.
And then inside of our square braces we'll say npm run start like so.
All right.
So that's pretty much it for our development Docker file.
We've ran exactly essentially exactly the same Docker file before.
So not a lot of confusion here.
I think that we've got a reasonable idea of what's going to happen.
Let's try flipping over to our terminal.
And we're going to figure out how we can run a Docker file with a custom file name.
Now, the reason I say a custom name is.
Remember, any time you run docker build, it's going to look for a file inside the current working
directory called just docker file.
Let's try running that right now and just see what happens.
I'll say docker build dot and you'll notice that we get a little error message here.
It says hey you don't have anything inside of here called Docker file.
So in order to make sure that we build our project using the Docker file.dev file, we're going to make
a little tweak to the docker build command.
So we're going to run Docker build.
And then we're going to add on a dash f f means we're trying to specify the file that's going to be
used to build out the image.
And we'll say docker file.dev.
And that's it.
We'll put the dot on there and that's it.
And there we go.
Okay.
So it's going to now load up our image.
It's going to create the Docker file and create the image.
Now as we're building the image you might see a couple of warnings appear here.
That's totally fine.
You could ignore the warnings.
If you see anything that specifically says error.
That's when we want to start to get a little bit concerned.
All right.
So let's take a quick pause right here and we'll continue in the next section after we successfully
built our image.