Reputation: 1820
I'm building this dockerfile using docker-compose and I need it to build native modules in docker (not just copy them from local). This only works when my local modules are built (npm install) As soon as I delete them this runs but there is no node_modules directory and it gives an error: Error: Cannot find module 'express'
FROM mhart/alpine-node:6
MAINTAINER Me
COPY package.json index.js lib /app/
WORKDIR /app
RUN apk add --no-cache make gcc g++ python && \
addgroup -S app && adduser -S -g app app && \
npm install && \
npm cache clean && \
apk del make gcc g++ python
USER app
And here is the app directory:
.dockerignore
.eslintignore
.eslintrc.js
Dockerfile
docker-compose.yml
index.js
lib
npm-debug.log
package.json
Upvotes: 0
Views: 712
Reputation: 1820
The problem was with the way docker binds the app folder from the host to the container. The second line in the volume section from my docker-compose.yml fixed it.
volumes:
- .:/app
- /app/node_modules
Upvotes: 1