My Setup
I’m working with a multi-service application that includes:
- api/ - Python Flask server running on port 5000 with SQLite database
- processor/ - Contains
app.jsfile that handles background tasks. The Flask server communicates with this service via JSON API on port8080. This service uses Redis for caching and saves files toprocessor/uploads/
My issue is specifically with the processor service.
processor/Dockerfile
FROM node:0.12
WORKDIR /processor
COPY package.json /processor/
RUN npm install
COPY . /processor/
docker-compose.yml
redis:
image: redis
processor:
build: ./processor
command: npm start
ports:
- "8080:8080"
volumes:
- processor/:/processor/
links:
- redis
The Problem
When I execute docker-compose build, everything appears to work correctly. All npm packages get installed to /processor/node_modules as expected:
npm WARN package.json [email protected] No README data
> [email protected] install /processor/node_modules/screenshot-tool/node_modules/phantomjs
> node install.js
However, when I run docker-compose up, I get this error:
processor_1 | Error: Cannot find module 'lodash'
processor_1 | at Function.Module._resolveFilename (module.js:336:15)
processor_1 | at Function.Module._load (module.js:278:25)
processor_1 | at Module.require (module.js:365:17)
processor_1 | at require (module.js:384:17)
processor_1 | at Object.<anonymous> (/processor/app.js:1:75)
The /processor/node_modules directory is completely empty both in the container and on the host machine.
If I manually run npm install on my host machine, everything works fine. But I want the container to manage all dependencies automatically.
What could be causing this issue? All required packages are properly listed in my package.json file.