Monokilho
Monokilho

Reputation: 71

Docker with npm install adds unwanted symlink

I'm trying to build a nodejs container for my project which requires a local module. On my package.json i got a relative link to a folder above, since there is where the local module is located. Everything seems to work correctly except that inside the container, the local module is added as symlink to the host machine (windows).

This behavior only happens when i build using the dockerfile, if i do npm install manually inside the container, the module is copied into the node_module as expected.

package.json entry:

"app-lib": "file:../app_lib"

docker file:

FROM node:8.9-alpine
ENV NODE_ENV production
WORKDIR /usr/src/app
COPY ["./Provider/package.json", "./Provider/package-lock.json*", "./Provider/npm-shrinkwrap.json*", "./"]
COPY ["./app_lib/package.json", "./app_lib/package-lock.json*", "./app_lib/npm-shrinkwrap.json*", "../app_lib/"]
RUN cd ../app_lib && npm install
COPY ./app_lib .
RUN cd ../app && npm install
COPY ./Provider .
EXPOSE 3001

Annoying symlink:

app-lib -> E:\work\app_server\app_lib\

Anyone got any suggestion on how to make it work right on build or why might be the underlying cause?

Upvotes: 2

Views: 819

Answers (1)

Tarun Lalwani
Tarun Lalwani

Reputation: 146630

Make sure you have node_modules in .dockerignore, else COPY ./app_lib . will overwrite the same and you will get the behaviour you see

Upvotes: 3

Related Questions