I am creating a dockerized PHP application and would like to separate the services as much as possible. I so far have separate nginx, mysql and php containers (which are all working correctly). However I am wondering where node/npm fits into this? I have npm packages for the the frontend and gulp tasks for the build etc.
I was wondering if it was best practice to then have a separate Node container that runs npm install / gulp? This seems the most appropriate, however I haven't seen any examples of anyone doing this! Plus when I did try this I had a lot of problems with the node_modules, but that's a story for another time!
Here is an example of my docker-compose file
version: '2'
services:
nginx:
build: './nginx'
ports:
- '8080:80'
restart: always
volumes:
- '.:/app'
- './nginx/app.conf:/etc/nginx/conf.d/app.conf'
php:
build: './php'
volumes:
- '.:/app'
- './nginx/app.conf:/etc/nginx/conf.d/app.conf'
mariadb:
image: mariadb:10.0
ports:
- '3310:3306'
volumes:
- './mariadb:/var/lib/mysql'
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_DATABASE=database_name
node:
image: node:boron
volumes:
- '.:/app'
- /app/node_modules
I'm currently working on a dockerized MEAN application (using docker-compose), there you will find how I handle the separation of a Node.js webserver (based on mhart/alpine-node image) and the MongoDB database.
https://github.com/alex-gru/docker-MEAN-ts-starter
Hope this helps!