我正在尝试从GitHub将node.js容器化应用部署到Azure应用服务,并收到以下错误:npm ERR! enoent ENOENT:没有此类文件或目录,请打开“ /home/site/wwwroot/package.json”。这是我的GitHub项目的链接:https://github.com/dukeace2005/proxy.git
当我从本地存储库手动创建docker映像,然后从Azure容器注册表手动部署时,一切正常。
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
答案 0 :(得分:1)
正如我在您的docker-compose文件中看到的那样,您使用了build
选项,如下所示:
version: '2.1'
services:
proxy:
image: proxy
build: .
environment:
NODE_ENV: production
ports:
- 3000:3000
但是在Azure Web App中,它当前不支持build
选项,因此,当您从带有docker-compose文件的Github部署它时,它将显示错误。有关更多详细信息,请参见Docker Compose options。您最好已经从映像中部署了它。