fly deploy using dockerfile fails

Trying to deploy my app using a dockerfile.
While using “docker build .” is working, “fly deploy” - is not.
Adding “–local-only” does not help.

I get the following messages:

#10 137.1 glob error [Error: EACCES: permission denied, scandir ‘/root/.npm/_logs’] {
#10 137.1 errno: -13,
#10 137.1 code: ‘EACCES’,
#10 137.1 syscall: ‘scandir’,
#10 137.1 path: ‘/root/.npm/_logs’
#10 137.1 }
#10 141.5 npm ERR! code EACCES
#10 141.5 npm ERR! syscall lstat
#10 141.5 npm ERR! path /root/.npm/_cacache/content-v2/sha512/2d/88/d9b040e109d6044fd8a416ee9d54f1a9d981fd0de8178dd253a12cc3f6b3ba7f2e2a891605a32118c29b3cf0eb1e2653f297634e7b6889ba11212fb22910
#10 141.5 npm ERR! errno -13
#10 141.5 npm ERR!
#10 141.5 npm ERR! Your cache folder contains root-owned files, due to a bug in
#10 141.5 npm ERR! previous versions of npm which has since been addressed.
#10 141.5 npm ERR!
#10 141.5 npm ERR! To permanently fix this problem, please run:
#10 141.5 npm ERR! sudo chown -R 501:20 “/root/.npm”

Sounds like an issue with file permissions perhaps related to packaging up files for use on a build (if I had to guess).

Part of the error message seems to indicate updating npm may fix it - is that possible in your setup? (the answer depends a bit on how the dockerfile is configured and which base images are used)

Thanks for the answer!
But I suspect the problem is related to how fly deploy executes Docker, for the reason that local docker build . works perfectly, while fly deploy - does not.

This is the Dockerfile:

FROM node:16.13.1
RUN apt-get update
RUN npm install -g npm@8.19.2
WORKDIR /app
COPY . ./
RUN npm run install-production
RUN npm run build-production
EXPOSE 8080
CMD npm run run-production

The only thing I suspect is COPY . ./ which copies the node_modules folder - which is not recommended.

Thanks again!

1 Like

Looks like it is an issue related to the different way “flyctl” treats the “.dockerignore” file…

To my knowledge the .dockerignore file is just being used by docker itself, and fly doesn’t actually attempt to read/parse it.

Can you show your .dockerignore file here? I’m assuming node_modules is defined within it?