First of all, you need to build an application to get the "dist" folder with the content ready to redistribute.
npm run build
In the project root, create a file named "Dockerfile" with the following content:
FROM nginx COPY nginx.conf /etc/nginx/nginx.conf WORKDIR /usr/share/nginx/html COPY dist/ .
The image extends the public nginx one.
Besides, we provide an external configuration to serve our application and copy the contents of the
dist folder into the image.
nginx configuration can be as following:
There are multiple deployment scenarios documented in the official documentation: "Deployment". Please refer to that article if you want to get more information on available options and best practices.
Now, let's build the image using the next command:
docker image build -t ng-docker .
Note the dot character at the end of the command as it is essential.
You can also list your local images to ensure the
ng-docker got created successfully.
docker image ls
Excluding the images you may already have created or pulled, you should see the at least the following output:
|ng-docker||latest||98b129bff2fc||24 seconds ago||114MB|