在同一容器中为python和nodejs进行多阶段构建

时间:2019-01-18 01:28:20

标签: docker docker-multi-stage-build

我需要同时访问同一容器中的pipenvFROM python:3.7 COPY Pipfile /app/Pipfile RUN pip install pipenv FROM node:8 npm install 。我认为实现此目标的最佳方法是使用多阶段构建。

如果我做这样的事情:

pipenv

如何确保不丢弃Private Sub Worksheet_Change(ByVal Target As Range) If Target.Column = 4 And Target.Row = 4 Then Target.Offset(10, 3) = Format(Now(), "YYYY-MM-DD HH:MM:SS") End If End Sub 二进制文件?我需要从上一阶段复制哪些文件,以便最终图像中可以使用pipenv?

1 个答案:

答案 0 :(得分:2)

在您的情况下,不需要

多阶段构建。从基本映像python:3.7开始并在其中安装节点,将是简单的解决方案

FROM python:3.7
COPY Pipfile /app/Pipfile
RUN pip install pipenv

# Using Debian, as root
RUN curl -sL https://deb.nodesource.com/setup_11.x | bash -
RUN apt-get install -y nodejs

你怎么知道python:3.7是debian?

$ docker run -ti --rm python:3.7 bash
root@eb654212ef67:/# cat /etc/*release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
root@eb654212ef67:/#

参考:

https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions-enterprise-linux-fedora-and-snap-packages

https://github.com/nodesource/distributions/blob/master/README.md

节点安装说明

Node.js v11.x:

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_11.x | bash -
apt-get install -y nodejs
Node.js v10.x:

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt-get install -y nodejs
Node.js v8.x:

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt-get install -y nodejs