gpt4 book ai didi

docker - 在 Docker 构建期间安装 brew 包不起作用

转载 作者:行者123 更新时间:2023-12-05 04:53:30 24 4
gpt4 key购买 nike

我正在尝试在 docker 构建期间使用以下 dockerfile 安装 arduino-cli(一个 Homebrew 程序包)。

docker 镜像似乎构建正确,但在我的网络服务器上运行时,我在日志中得到以下输出。

注意这个问题好像和Installing homebrew packages during Docker build类似,但接受的答案似乎对我没有帮助。

这是否表明 arduino-cli 没有正确安装,或者只是路径没有正确链接?

FileNotFoundError: [Errno 2] No such file or directory: 'arduino-cli': 'arduino-cli'
FROM python:3.6

RUN apt-get update && apt-get install -y git curl binutils clang make
RUN git clone https://github.com/Homebrew/brew ~/.linuxbrew/Homebrew \
&& mkdir ~/.linuxbrew/bin \
&& ln -s ../Homebrew/bin/brew ~/.linuxbrew/bin \
&& eval $(~/.linuxbrew/bin/brew shellenv) \
&& brew --version \
&& brew install arduino-cli \
&& arduino-cli version
ENV PATH=~/.linuxbrew/bin:~/.linuxbrew/sbin:$PATH

RUN mkdir -p /opt/services/djangoapp/src
WORKDIR /opt/services/djangoapp/src

RUN pip install gunicorn django psycopg2-binary whitenoise

COPY . /opt/services/djangoapp/src

EXPOSE 8000

COPY init.sh /usr/local/bin/

RUN chmod u+x /usr/local/bin/init.sh
ENTRYPOINT ["init.sh"]

最佳答案

这很可能是 $PATH 问题。上述答案对您不起作用的原因是您在 $PATH 尚未更改 时尝试使用 arduino-cli。这应该使它工作:

RUN git clone https://github.com/Homebrew/brew ~/.linuxbrew/Homebrew \
&& mkdir ~/.linuxbrew/bin \
&& ln -s ../Homebrew/bin/brew ~/.linuxbrew/bin \
&& eval $(~/.linuxbrew/bin/brew shellenv) \
&& brew --version \
&& brew install arduino-cli

# first change PATH
ENV PATH=~/.linuxbrew/bin:~/.linuxbrew/sbin:$PATH

# then run
RUN arduino-cli version

# not vice-versa

关于docker - 在 Docker 构建期间安装 brew 包不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66040170/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com