Are there any up to date Docker container for the IDE?.
My heart always sinks when I have to install something that uses an interpreted language like Python, and there is no Docker image. Every single time, there is some dependency problem.
Sure enough, I install Arduino IDE, and it's complaining python is missing. It's not. After messing with paths, and googling, and installing different versions, I give up.
I asked ChatGPT4 to write me a docker file. With a few tweeks, this works:
Dockerfile:
# Use the official Ubuntu base image for the intermediate container
FROM ubuntu:latest as intermediate
# Install required dependencies for the intermediate container
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl \
unzip ca-certificates && \
rm -rf /var/lib/apt/lists/*
# Fetch the latest Arduino Pro IDE release version
RUN curl -L -o arduino.zip $(curl --silent https://api.github.com/repos/arduino/arduino-ide/releases/latest | grep "browser_download_url.*Linux_64bit.zip" | cut -d : -f 2,3 | xargs)
# Unzip the Arduino Pro IDE
RUN unzip /arduino.zip -d /opt && \
rm /arduino.zip
RUN mv /opt/arduino* /opt/arduino-ide
# Start building the final image
FROM ubuntu:latest
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
# Install required dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
software-properties-common \
ca-certificates \
python2 \
python-pip \
git \
libx11-6 \
libxext-dev \
libxrender-dev \
libxtst-dev \
libcanberra-gtk-module \
libxshmfence1 libglu1 \
libnss3-dev libgdk-pixbuf2.0-dev libgtk-3-dev libxss-dev libsecret-1-dev \
libcanberra-gtk3-module x11-apps && \
RUN curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py && \
python2 get-pip.py && \
rm get-pip.py && \
pip install pyserial
rm -rf /var/lib/apt/lists/*
# Copy the extracted Arduino Pro IDE from the intermediate container
COPY --from=intermediate /opt/arduino-ide /opt/arduino-ide
RUN ln -s /usr/bin/python2 /usr/bin/python
ENV DISPLAY :0
WORKDIR /root
# Set the entrypoint to the Arduino Pro IDE
ENTRYPOINT ["/opt/arduino-ide/arduino-ide","--no-sandbox"]
arduino.sh:
#!/bin/bash
WORKDIR=$(dirname "$0")
XSOCK=/tmp/.X11-unix
xhost +SI:localuser:root
docker run -it --rm --net=host \
-v $XSOCK:$XSOCK:ro \
-v $WORKDIR:/root \
--device=/dev/ttyUSB0 --device=/dev/ttyACM0 \
-e DISPLAY=$DISPLAY \
--name arduino-ide arduino-ide
xhost -SI:localuser:root
Put those two files in a directory,
chmod +x arduino.sh
docker build -t arduino .
./arduino.sh
system
Closed
November 3, 2023, 10:46pm
3
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.