1

For my project I have done the following Dockerfile in order to have a base to develop node.js with express.js applications:

FROM node:alpine
MAINTAINER "Desyllas Dimitrios"

ENV NEO4J_HOST=""
ENV NEO4J_USER=""
ENV NEO4J_PASSWORD=""
ENV MONGO_CONNECTION_STRING=""
ENV LOGS_DIR="/var/log/data_map"

COPY ./docker_scripts/entrypoint_dev.sh /usr/local/bin/entrypoint.sh

RUN chmod +x /usr/local/bin/entrypoint.sh &&\
    chown root:root /usr/local/bin/entrypoint.sh &&\
    mkdir -p /opt/map &&\
    mkdir -p /var/log/data_map &&\
    chmod 0666 /var/log/data_map &&\
    npm install nodemon -g

EXPOSE 7474
VOLUME /var/log/data_map
VOLUME /opt/map

WORKDIR /opt/map

ENTRYPOINT ["nodemon src/server.js"]

But over my project I have a folder containing twig templates, the folder is the src/views one. On my application I configurre the use of twig templates like this:

const express=require('express');
const app=express();

app.set('views', __dirname + '/views');
app.set('view engine', 'twig');
app.set('twig options', {
    strict_variables: false
});

And over a route I use:

router.get('/my-route',function(req,res,next){
  res.render('my-route.html.twig',{
    'title': "Main Panel"
  });
});

My question is how I will make my docker image to rerun the app even when the template has been changed? With the current use I cannot restart my app when a change happens over a template in order to reload the new one.

Please keep in mind that I run my nodejs application with nodemon in order to rerun the application during the file changes when I develop my software.

Edit 1:

What I want to do is to relaunch my application inside the container when I change over a template of even on frontend assets In the same way I relaunch it when I change server-side code.

2
  • Have you seen the api docs for the fs library? It fires an event whenever a watched file is updated, similarly to nodemon. Commented Jan 10, 2018 at 23:08
  • Well not exactly what I needed. It was my fault that I did not explained it well. Commented Jan 10, 2018 at 23:22

1 Answer 1

3

Nodemon allows you to specify other extensions to watch other than just javascript.

Try changing

ENTRYPOINT ["nodemon src/server.js"]

To

ENTRYPOINT ["nodemon -e js,twig src/server.js"]

You may need to pass more file extensions in your arguments for your use case.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.