Mon fichier docker exécute npm install, mais après l'exécution de docker-compose build
le dossier node_modules dans mon dossier hôte reste vide même après avoir vu la construction. Comment faire pour que le dossier soit visible dans l'hôte également ?
Il s'agit de docker-compose.yml :
Voici mon docker-compose
version: "2"
volumes:
mongostorage:
services:
app:
build: ./app
ports:
- "3000"
links:
- mongo
- redis
command: node ./bin/www
nginx:
build: ./nginx
ports:
- "80:80"
links:
- app:app
mongo:
image: mongo:latest
environment:
- MONGO_DATA_DIR=/data/db
volumes:
- mongostorage:/data/db
ports:
- "27017:27017"
redis:
image: redis
volumes:
- ./data/redis/db:/data/db
ports:
- "6379:6379"
Voici le fichier docker dans l'application
FROM node:6.3
RUN mkdir -p /var/www/app
WORKDIR /var/www/app
VOLUME /var/www/app
COPY . /var/www/app
COPY package.json /var/www/app
RUN npm install
package.json
{
"name": "app",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node app.js"
},
"dependencies": {
"body-parser": "^1.13.3",
"cookie-parser": "~1.3.5",
"debug": "~2.2.0",
"express": "~4.13.1",
"helmet": "^3.0.0",
"jade": "~1.11.0",
"redis": "^2.6.2",
"serve-favicon": "~2.3.0"
},
"devDependencies": {
"gulp": "^3.9.1",
"gulp-autoprefixer": "^3.1.1",
"gulp-complexity": "^0.3.2",
"gulp-concat": "^2.6.1",
"gulp-cssnano": "^2.1.2",
"gulp-less": "^3.3.0",
"gulp-uglify": "^1.5.4",
"gulp-watch": "^4.3.11",
"strip-debug": "^1.1.1",
"util": "^0.10.3"
}
}
docker logs
pour le conteneur de l'application revient après docker-compose up
erreur :
module.js:442
throw err;
^
Error: Cannot find module 'dotenv'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/var/www/nodeapp/app.js:3:1)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)