Running our application on Docker

Before we can run our application, we will need to create a Docker image using our Dockerfile. Open a new Terminal and navigate to the project root folder. Once you are there, run the following command to build our Docker image:

$ cd /some/path/deployme
$ docker build -t mydeploymeapp .

Sending build context to Docker daemon 130.9MB

Step 1/4 : FROM nginx:alpine
Digest: sha256:17c4704e19a11cd47545fa3c17e6903fc88672021f7f907f212d6663baf6ab57
Status: Downloaded newer image for nginx:alpine
---> 91ce6206f9d8
Step 2/4 : COPY default.conf /etc/nginx/conf.d/default.conf
---> 0e744f0e2556
Step 3/4 : COPY index.html /usr/share/nginx/html/index.html
---> 092ad92d0d5c
Step 4/4 : COPY scripts /usr/share/nginx/html/scripts
---> 6d097542eec5
Successfully built 6d097542eec5
Successfully tagged mywebapp:latest

We use the docker build command to build a new image. The -t option allows us to give our image a name, in this case, our image is called mydeploymeapp. Pay attention to the period (.) in the last command argument; the docker build command uses a Dockerfile to build the new image. We specify the path of this Dockerfile in the last option of the command; as this file is in the root folder where we are running docker build, we should use the period symbol to specify the current folder, which in this case contains the Dockerfile.

Once the build process is finished, we will have the Successfully built message.

Now we are ready to start our application. Go ahead and run the following command to start a new mydeploymeapp Docker container:

$ docker run -p 8000:80 mywebapp

We used the docker run command to start a new container and pass the -p option to map our host 8000 port to the NGINX 80 port, which is listening inside the container. The last argument is the Docker image that we want to create, in this case, our application's image.

Cool! Our application is up and running. Let's navigate to http://localhost:8000 and you should see the following page:

That's it! We have successfully deployed our Aurelia application on our local server using Docker and NGINX. You can install Docker on your remote server and follow the same steps we did in this section to install any Aurelia application.

Let's learn in the following sections how to deploy apps to the cloud. Keep reading!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset