3
votes

I am trying to deploy node.js containerized app to Azure App Services from my GitHub and getting the following error: npm ERR! enoent ENOENT: no such file or directory, open '/home/site/wwwroot/package.json'. This is a link to my GitHub project: https://github.com/dukeace2005/proxy.git

When I create docker image manually from my local repo and then manually deploy from Azure container registry, everything works just fine.

Dockerfile:

FROM node:10.13-alpine
ENV NODE_ENV production
WORKDIR /usr/src/app
COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"]
RUN npm install --production --silent && mv node_modules ../
COPY . .
EXPOSE 8080
CMD npm start

2019-08-26T05:46:09.861966773Z PATH="$PATH:/home/site/wwwroot" npm start
2019-08-26T05:46:09.866880267Z Checking if node_modules was compressed...
2019-08-26T05:46:09.867015467Z Done.
2019-08-26T05:46:11.001090444Z npm ERR! path /home/site/wwwroot/package.json
2019-08-26T05:46:11.001728443Z npm ERR! code ENOENT
2019-08-26T05:46:11.002710642Z npm ERR! errno -2
2019-08-26T05:46:11.003222742Z npm ERR! syscall open
2019-08-26T05:46:11.019177623Z npm ERR! enoent ENOENT: no such file or directory, open '/home/site/wwwroot/package.json'
2019-08-26T05:46:11.019901022Z npm ERR! enoent This is related to npm not being able to find a file.
2019-08-26T05:46:11.020380922Z npm ERR! enoent
1
Forget to mention that when I am creating container manually I do it on Windows using Docker toolbox from VS Code, while I am deploying to Linux instance. Like I mentioned already manual flow works just fine, but CI/CD fails.Duke Ace

1 Answers

2
votes

As I see in your docker-compose file, you use the build option like below:

version: '2.1'

services:
  proxy:
    image: proxy
    build: .
    environment:
      NODE_ENV: production
    ports:
      - 3000:3000

But in Azure Web App, it does not support the build option currently, so when you deploy it from the Github with the docker-compose file, it will show the error. For more details, see Docker Compose options. You'd better deploy it from the image already.