A Multi-stage Dockerfile for Angular

How to write a multi-purpose Dockerfile for Angular Projects

Node Dockerfile for Angular development

In this story, I am trying to show how to write a Dockerfile for an Angular project that supports both development and production goals.

I took this tutorial here and changed it to fit in my project and environment requirements.

I want to have an independent environment for Angular from my host machine. Why? Because Angular releases new versions very quickly that my team and project cannot match its speed. There are other reasons as well :).

Let’s see what I have changed here.

First of all, I need to have a very typical Nodejs enabled image and I will install my library baskets in it.

FROM node:10 AS developer

Second, for the build, which I’d like to use as a replacement for my build pipelines, I am using an Alpine image. As you can see here, I am using yarn instead of npm which is obvious.

And finally, again an Alpine image will host the production version of my application.

Note: The Nginx is using the following file as defulat.conf

server {

If you are curious to see how it looks like at the end check this out

ng build — prod

Please See here how to create a .Net Core Dockerfile.

One shot is not enough