Reputation: 10030
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.
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.
Upvotes: 1
Views: 1258
Reputation: 873
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.
Upvotes: 3