DEV Community

Cover image for Setting up Docker + TypeScript + Node (Hot reloading code changes in a running container) 🦄 🚀

Setting up Docker + TypeScript + Node (Hot reloading code changes in a running container) 🦄 🚀

Darian Sampare on January 31, 2021

I love TypeScript, and I love Docker. Putting these two together, however, can be a giant pain in the ass. Today I am going to walk you through ...
Collapse
 
tomcrawford profile image
Tom Crawford

In order to make the production container, I had to add --build to the docker up command, so the up-prod Makefile entry became:

docker-compose -f docker-compose.yml -f docker-compose.prod.yml up --build -d

Collapse
 
ryands17 profile image
Ryan Dsouza • Edited

Great article! We would need to restart the container on installing a new module right?

Collapse
 
dariansampare profile image
Darian Sampare • Edited

Thanks Ryan! Yes you would. Most of it gets cached so rebuilding after installing another package should be much faster than the initial build.

Collapse
 
aadit017 profile image
Aadit

💯

Collapse
 
babatunde50 profile image
Babatunde Ololade

Great article, thanks

Collapse
 
dancrtis profile image
Dan Curtis

Thank you! I was wasting so much time flipping between developing with npm scripts and then testing with docker...hot reloading for the win!

Collapse
 
jamiegilmartin profile image
jamie gilmartin

This was very well done. Thanks!

Collapse
 
aadityasiva profile image
Aadityasiva

Nice

Collapse
 
spock123 profile image
Lars Rye Jeppesen

Doesn't this make a production image containing all the devDependencies? That's not what we want

Collapse
 
zenb0t profile image
Zenb0t

Saved me from a massive headache. Thanks a lot!

Collapse
 
santdev404 profile image
santdev404

Excellent article!!

Collapse
 
stelam profile image
Stéphane Lam

Thank you

Collapse
 
monkekode profile image
monkekode

So you put all of the dev dependencies, TS sources to the docker image? Aren't you supposed to specifically not do that?

Collapse
 
douglasbrandao00 profile image
Douglas Brandão • Edited

Nice work Darian, I've been struggle with this setup for so long.
Will use this as template from now on!

Collapse
 
natnaelsisay profile image
Natnael Sisay

Well you just saved me hours of work, Thank you