|
| 1 | +# Copyright 2022 Blues Inc. All rights reserved. |
| 2 | +# Use of this source code is governed by licenses granted by the |
| 3 | +# copyright holder including that found in the LICENSE file. |
| 4 | + |
| 5 | +# Build development environment |
| 6 | +# docker build --file Dockerfile.arduino-cli --tag arduino-buildpack . |
| 7 | + |
| 8 | +# Launch development environment |
| 9 | +# docker run --device /dev/bus/usb/ --interactive --rm --tty --user blues --volume "$(pwd)":/host-volume/ arduino-buildpack bash |
| 10 | + |
| 11 | +# Define global arguments |
| 12 | +ARG DEBIAN_FRONTEND="noninteractive" |
| 13 | +ARG UID=1000 |
| 14 | +ARG USER="blues" |
| 15 | + |
| 16 | +# POSIX compatible (Linux/Unix) base image |
| 17 | +FROM debian:stable-slim |
| 18 | + |
| 19 | +# Import global arguments |
| 20 | +ARG DEBIAN_FRONTEND |
| 21 | +ARG UID |
| 22 | +ARG USER |
| 23 | + |
| 24 | +# Define local arguments |
| 25 | +# ARG ARDUINO_CLI_CHECKSUM="068f0a69ffecd5688e0b4bc02609720af57ec1aa60e5ea6a2879af3ed1dc0d9b" |
| 26 | +ARG ARDUINO_CLI_VERSION=0.21.1 |
| 27 | +ARG BINDIR=/usr/local/bin |
| 28 | +ARG ECHO_BC_FILE='$bcfile' |
| 29 | + |
| 30 | +# Define environment variables |
| 31 | +ENV ARDUINO_UPDATER_ENABLE_NOTIFICATION=false |
| 32 | + |
| 33 | +# Create Non-Root User |
| 34 | +RUN ["dash", "-c", "\ |
| 35 | + addgroup \ |
| 36 | + --gid ${UID} \ |
| 37 | + \"${USER}\" \ |
| 38 | + && adduser \ |
| 39 | + --disabled-password \ |
| 40 | + --gecos \"\" \ |
| 41 | + --ingroup \"${USER}\" \ |
| 42 | + --uid ${UID} \ |
| 43 | + \"${USER}\" \ |
| 44 | + && usermod \ |
| 45 | + --append \ |
| 46 | + --groups \"dialout,plugdev\" \ |
| 47 | + \"${USER}\" \ |
| 48 | +"] |
| 49 | + |
| 50 | +# Establish development environment |
| 51 | +RUN ["dash", "-c", "\ |
| 52 | + apt-get update --quiet \ |
| 53 | + && apt-get install --assume-yes --no-install-recommends --quiet \ |
| 54 | + bash \ |
| 55 | + ca-certificates \ |
| 56 | + curl \ |
| 57 | + python3 \ |
| 58 | + python-is-python3 \ |
| 59 | + python3-pip \ |
| 60 | + ssh \ |
| 61 | + && pip install \ |
| 62 | + pyserial \ |
| 63 | + && apt-get clean \ |
| 64 | + && apt-get purge \ |
| 65 | + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ |
| 66 | +"] |
| 67 | + |
| 68 | +# Download/Install Arduino CLI |
| 69 | +RUN ["dash", "-c", "\ |
| 70 | + curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=${BINDIR} sh -s ${ARDUINO_CLI_VERSION} \ |
| 71 | +# && arduino-cli completion bash > /usr/share/bash-completion/completions/arduino-cli.sh \ |
| 72 | + && mkdir -p /etc/bash_completion.d/ \ |
| 73 | + && arduino-cli completion bash > /etc/bash_completion.d/arduino-cli.sh \ |
| 74 | + && echo >> /etc/bash.bashrc \ |
| 75 | +# && echo \"for bcfile in /usr/share/bash-completion/completions/* ; do\" >> /etc/bash.bashrc \ |
| 76 | +# && echo \"for bcfile in /etc/bash_completion.d/* ; do\" >> /etc/bash.bashrc \ |
| 77 | +# && echo \" [ -f \\\"${ECHO_BC_FILE}\\\" ] && . \\\"${ECHO_BC_FILE}\\\"\" >> /etc/bash.bashrc \ |
| 78 | +# && echo \"done\" >> /etc/bash.bashrc \ |
| 79 | +"] |
| 80 | + |
| 81 | +# Configure Arduino CLI |
| 82 | +USER ${USER} |
| 83 | +RUN ["dash", "-c", "\ |
| 84 | + arduino-cli config init \ |
| 85 | + && sed --in-place 's|^ additional_urls:.*$| additional_urls: [\ |
| 86 | + https://raw.githubusercontent.com/stm32duino/BoardManagerFiles/main/package_stmicroelectronics_index.json,\ |
| 87 | + https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json,\ |
| 88 | + https://raw.githubusercontent.com/sparkfun/Arduino_Apollo3/main/package_sparkfun_apollo3_index.json,\ |
| 89 | + https://raw.githubusercontent.com/adafruit/arduino-board-index/gh-pages/package_adafruit_index.json,\ |
| 90 | + https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json]|gm' ${HOME}/.arduino15/arduino-cli.yaml \ |
| 91 | + && arduino-cli core update-index \ |
| 92 | + && arduino-cli core install arduino:avr \ |
| 93 | + && arduino-cli core install arduino:mbed_nano \ |
| 94 | + && arduino-cli core install arduino:samd \ |
| 95 | + && arduino-cli core install STMicroelectronics:stm32 \ |
| 96 | + && arduino-cli core install esp32:esp32 \ |
| 97 | + && arduino-cli core install SparkFun:apollo3 \ |
| 98 | + && arduino-cli core install adafruit:nrf52 \ |
| 99 | + && arduino-cli core install adafruit:samd \ |
| 100 | + && arduino-cli core install rp2040:rp2040 \ |
| 101 | +"] |
| 102 | + |
| 103 | +# Set Execution Environment |
| 104 | +WORKDIR /host-volume |
| 105 | + |
| 106 | +ENTRYPOINT ["arduino-cli"] |
| 107 | + |
| 108 | +CMD ["help"] |
0 commit comments