Python Dockerfile 中用于 Node.js 项目的库

Python libraries in Dockerfile for Node.js Project

我正在尝试将我的 Node.js 项目上传到 AWS Elastic Beanstalk 上的 Docker 平台。我 运行 在 Docker 文件中添加 python 库时遇到问题。 使用此文件部署很好:

FROM node:8.16
WORKDIR /opt/app
COPY package.json package-lock.json* ./
RUN npm cache clean --force && npm install
COPY . /opt/app
ENV PORT 80
EXPOSE 80
CMD [ "npm", "start" ]

但是一旦我为 Docker 文件添加了 Python 库:

FROM node:8.16
WORKDIR /opt/app
COPY package.json package-lock.json* ./
RUN npm cache clean --force && npm install
COPY . /opt/app

FROM python:3.7    
COPY requirements.txt /tmp/
RUN pip install --requirement /tmp/requirements.txt
COPY . /tmp/

ENV PORT 80
EXPOSE 80
CMD [ "npm", "start" ]

我在部署时遇到错误:

Failed to run Docker container: a46e6adbe0fee8d3 docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"npm\": executable file not found in $PATH": unknown.. Check snapshot logs for details.

提前感谢您的帮助

docker reference for FROM 中所述,虽然允许在单个 Dockerfile 中包含多个 FROM 指令:

Each FROM instruction clears any state created by previous instructions.

如果您希望在包含 node.js 和 python 3 的环境之上构建您的应用程序,我建议您查看 docker hub。也许 this one 会有所帮助。