My London Stops

Getting around London without a car would be impossible if not for The Underground, otherwise known as the tube. These are the tube stops that make up my daily life around the city. At the top…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Deploy your Create React App with Docker and Nginx

This is not okay, I know the website is static but the user doesn’t need to know.

We will now need to create a nginx configuration for our server. The reason I choose nginx over node is mostly because it has been proven to be faster for static assets but you can totally do this with node.

A configuration file for nginx is a nginx.conf file so let’s start by creating that file and start coding it:

This is a pretty standard configuration for nginx and we tell it where to show our files and what the cache expiration date is. There is also some helpers for 404 and logs.

Now that we have our nginx config we can now create our Dockerfile and we will start by stating what is the base image we will be using:

After this we need to tell docker what it needs to run our app and in this case we need to do three things:

Details on how to do this are below:

Now to finish our Dockerfile we need to tell it what command to run and for that we will the nginx cli and pass it as the entrypoint in our Dockerfile:

You can now build and tag this image with:

And then run it with:

We now have static routes on our static projects! If someone hits any route on your webapp this will be redirected to index.html and your app will work flawlessly.

Routes 🎉

Add a comment

Related posts:

Obat Herpes Pada Tangan

Obat Herpes Pada Tangan — Pernahkah Anda mendengar tentang penyakit herpes? Atau bahkan Anda pernah mengalaminya? Herpes adalah penyakit kulit yang penyebab utamanya adalah virus, biasanya akan…

Building A Continuous Delivery Pipeline Using Jenkins

This article on Continuous Delivery will help you to understand the process of continuous delivery in detail by building a pipeline.

A goddess is born!

I wanted to express through this blog what I went through these past 2 months, which totally changed my approach to life. A life where I now choose to appreciate who I am and what I have instead of…