Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing brew package during Docker build not working

I am trying to install arduino-cli (a homebrew package) during the docker build, with the following dockerfile.

The docker image seems to build correctly, but when run on my web server, I am getting the following output in my logs.

Note that this problem seems to be similar to Installing homebrew packages during Docker build, but the accepted answer doesn't seem to help me.

Does this seem to indicate that arduino-cli was not installed correctly, or just that the path hasn't been linked correctly?

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"]
like image 941
Austin Avatar asked Feb 14 '26 11:02

Austin


1 Answers

It's most likely the $PATH problem. The reason why the mentioned answer did not work for you is that you are trying to use arduino-cli when $PATH is not yet changed. This should make it work:

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
like image 56
anemyte Avatar answered Feb 16 '26 01:02

anemyte