Angular 2 GIT Deployment Dockerized

Rogério R. Alcântara
2 min readDec 13, 2017

And this time, I needed to get an Angular 2 App deployed from a Git repository.

Not a big deal, just a simple git clone, running some npm scripts and voilà: App up and running, eh?

Yes.. but no.

"Environments! Environments everywhere!"

Usually, as you might be aware of, Angular apps have many environments, such as prod, staging and so on. And I needed to get all of then running. Should the whole thing be replicated for each environment?

Plus, this seems to be something that I might be facing anytime soon. And I would have to spend another hour just doing it all over again — thanks to my ̶s̶h̶i̶t̶t̶y̶ memory.

Not good.

One Dockerfile to rule them all

The easiest (and fastest) way that I’ve come up with was to get a simple Dockerfile ready to go so that I didn’t need duplicate anything — nor figure it out again next time. Check this out:

After all, what the heck is "Cowabunga"?

And now, every time that I need an Angular App from a Git Repository up and running quick quick, we'd just run a few commands and we are good to go.

You’re welcome future self.

Is there any easier way of doing this?

Please, don’t be shy, let me know! :)

[Updated at 2017/12/14]: Very special thanks to Mika ANDRIANARIJAONA, who wasn’t shy and opened my eyes to the amazing world of multi-stage builds and alphine. 🙏🏽

--

--