我有个问题。我想安装Python
和Node.js
在同一个图像中。但是复制package.json有问题。错误说no such file or directory, open '/opt/app/src/package.json'
。那么这里的问题是什么?我可能做错了什么?
我查看了Docker-compose up : no such file or directory, open '/usr/src/app/package.json',但我不知道我的错误在哪里。
Dockerfile
FROM python:3.7-slim AS build
RUN mkdir -p /opt/app/src
COPY ./requirements.txt /opt/app/src
RUN pip install -r /opt/app/src/requirements.txt
FROM node:14-slim
RUN mkdir -p /opt/app/src
WORKDIR /opt/app/src
COPY --from=build package-*.json ./
RUN npm install
EXPOSE 4001
CMD npm start
结构
|-- app.js
|-- requriments.txt
|-- test.js
|-- package.json
|-- routes
|-- |-- model.py
|-- |-- post_price.js
码头工人-compose.yml
version: '3.8'
services:
backend:
container_name: backend_airbnb
image: backend_airbnb
expose:
- "4001"
ports:
- "4001:4001"
networks:
- backendProxyNetwork
networks:
backendProxyNetwork:
external: true
错误
CONTAINERS
Attaching to backend_airbnb
backend_airbnb | npm ERR! code ENOENT
backend_airbnb | npm ERR! syscall open
backend_airbnb | npm ERR! path /opt/app/src/package.json
backend_airbnb | npm ERR! errno -2
backend_airbnb | npm ERR! enoent ENOENT: no such file or directory, open '/opt/app/src/package.json'
backend_airbnb | npm ERR! enoent This is related to npm not being able to find a file.
backend_airbnb | npm ERR! enoent
backend_airbnb |
backend_airbnb | npm ERR! A complete log of this run can be found in:
backend_airbnb | npm ERR! /root/.npm/_logs/2022-02-21T08_33_58_188Z-debug.log
backend_airbnb exited with code 254