Docker, dev environnement, nodejs and starting

I m trying to learn about Docker.

To understand a bit more how it works, I tried the samples, and finally decided to create my own docker environnement. I m running on Windows 10, and I m building NodeJs application.

Actually, my working flow is all about TDD.

What I want to make is simply creating a container in which I can start my tests and eventually run my web server.

In my package.json, I have set two scripts, test and start. In test, I simply run my mocha tests, and in start, I run my tests, if it’s okay, I build my dist and run the server.

From now, I need a container that allows me to run my tests and start my server.

My first question is : can I have multiple command to start on a docker container ? For example, I don’t want to start my application any time I write a test. I simply need to launch my tests, and when I think my function is okay, I run the server and check that all is working.

My second question is that possible to keep only one dockerfile for dev and prod env ? So I can be iso on my server and locally.

My third question is : could I run the following dockerfile without rebuilding it when I add some code ? (I have read about volumes, but I don’t know how to make them work, and I need to have my codebase in my container, not outside)

Lastly, I was wondering how to manage git in this case ? Inside or outside the container ?

Here the only dockerfile I have written :

FROM node:4-onbuild

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

CMD [ "npm", "test" ]

Multiple question that I don’t find answers… Hope you can help me :confused:

Please watch this video by David Gageot that will explain how to use Docker as Developer in his Dockercon talk.

It will answer most of your question and also Aanand Prasad has for live debugging

1 Like