Reputation: 41
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"]
Upvotes: 3
Views: 2197
Reputation: 2749
This might sound like madness but might I suggest using a [multi stage dockerfile][1] for this. This would eliminate cruft on your container and reduce security access points.
FROM homebrew/brew:latest AS brew
RUN brew update
RUN brew install arduino-cli
# RUN brew list ardunio-cli
FROM python:3.6
COPY --from=brew /usr/local/Cellar /user/local
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"]
There may be some addtional symbolic lings to make to get the brew files working but your end container will be much more slim and safe to use.
Upvotes: 1
Reputation: 20176
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
Upvotes: 1