How do i automatically load code changes using docker fig

426 views Asked by At

I have a simple node program app.js
I mounted app.js file containing folder to a docker container.
When i do fig up it works.
But when i change contents of app.js and do fig stop and fig up again the changes are not loaded.
How can i make sure fig reloads / rebuilds image every time i bring it up ?

I tried various combination but no luck.
how to fix this?

2

There are 2 answers

0
Johannes Reuter On

You need to call "fig build" to rebuild the container. I think it is easier to mount a directory on the host-system (via ADD in the dockerfile), you don't have to rebuild the container everytime then.

1
debianmaster On

Just mounting the volume (without actually using ADD in Dockerfile) helped me test on latest code every time i make a fig up

app.js
var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end("hello world 5"); }).listen(3001);

Dockerfile FROM cjonagam/centos-nodejs-0.10.33 RUN mkdir /home/test2 WORKDIR /home/test2 EXPOSE 3001

app: build: . volumes: - .:/home/test2 ports: - "3001:3001" command: node app.js