From 8f604facd933b2fd7493230c9ec66d514fba2a36 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Fri, 20 Nov 2020 00:31:38 -0800 Subject: [PATCH] Update our docker config to use a layout that better matches arduino-cli --- bin/run-docker | 21 +++++++++++++-------- etc/Dockerfile | 17 ++++++----------- etc/docker-entrypoint.sh | 20 ++++++++++++-------- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/bin/run-docker b/bin/run-docker index 062ad436..c00b8f58 100755 --- a/bin/run-docker +++ b/bin/run-docker @@ -13,25 +13,28 @@ fi if [ "${uname_S}" = "Darwin" ]; then - ARDUINO_LOCAL_LIB_PATH="${ARDUINO_LOCAL_LIB_PATH:-${HOME}/Documents/Arduino}" # This stops macos from copying resource forks into thigns like tar export COPYFILE_DISABLE=true else ARDUINO_LOCAL_LIB_PATH="${ARDUINO_LOCAL_LIB_PATH:-${HOME}/Arduino}" fi -BOARD_HARDWARE_PATH="${BOARD_HARDWARE_PATH:-${ARDUINO_LOCAL_LIB_PATH}/hardware}" - echo "Preparing Kaleidoscope and the bundle..." XFER_DIR="$(pwd)/.docker_xfer" mkdir -p "${XFER_DIR}" tar -cf "${XFER_DIR}/kaleidoscope.tar" \ - --exclude .docker_xfer --exclude .git --exclude _build --exclude testing/googletest/build \ + --exclude .arduino/data \ + --exclude bin/arduino-cli \ + --exclude .docker_xfer \ + --exclude .git \ + --exclude _build \ + --exclude testing/googletest/build \ . -(cd "${BOARD_HARDWARE_PATH}/keyboardio" && tar -cf "${XFER_DIR}/bundle.tar" \ +echo "The bundle is coming from ${ARDUINO_DIRECTORIES_USER}/hardware/keyboardio" +(cd "${ARDUINO_DIRECTORIES_USER}/hardware/keyboardio" && tar -cf "${XFER_DIR}/bundle.tar" \ --exclude .git --exclude avr/libraries/Kaleidoscope .) echo "Building the docker image..." @@ -39,11 +42,13 @@ docker build -q -t kaleidoscope/docker etc # We do want word splitting since there are multiple options here # shellcheck disable=SC2086 docker run --rm $DOCKER_RUN_INTERACTIVE_OPTS \ - --tmpfs /kaleidoscope:exec \ + --mount type=tmpfs,destination=/kaleidoscope:exec \ --mount type=bind,source="${XFER_DIR}",destination=/kaleidoscope-src,consistency=delegated,readonly \ --mount type=volume,source=kaleidoscope-persist,destination=/kaleidoscope-persist,consistency=delegated \ - --mount type=volume,source=kaleidoscope-googletest-build,destination=/kaleidoscope/hardware/keyboardio/avr/libraries/Kaleidoscope/testing/googletest/build,consistency=delegated \ - --mount type=volume,source=kaleidoscope-build,destination=/kaleidoscope/hardware/keyboardio/avr/libraries/Kaleidoscope/_build,consistency=delegated \ + --mount type=volume,source=kaleidoscope-googletest-build,destination=/kaleidoscope/testing/googletest/build,consistency=delegated \ + --mount type=volume,source=kaleidoscope-build,destination=/kaleidoscope/_build,consistency=delegated \ + --env ARDUINO_DIRECTORIES_DATA=/arduino-cli/data \ + --env ARDUINO_DIRECTORIES_USER=/kaleidoscope/.arduino/user/ \ kaleidoscope/docker "$*" diff --git a/etc/Dockerfile b/etc/Dockerfile index 2f587e4a..7b6ac85a 100644 --- a/etc/Dockerfile +++ b/etc/Dockerfile @@ -3,20 +3,16 @@ LABEL maintainer="Keyboard.io, inc" RUN apt-get -qq update && \ DEBIAN_FRONTEND=noninteractive \ - apt-get -qq install -y xz-utils curl make build-essential libxtst-dev cmake ccache + apt-get -qq install -y xz-utils curl make build-essential libxtst-dev cmake ccache vim RUN ccache --set-config=cache_dir=/kaleidoscope-persist/ccache/cache -ENV ARDUINO_VERSION "1.8.13" - -WORKDIR /usr/local -RUN curl https://downloads.arduino.cc/arduino-${ARDUINO_VERSION}-linux64.tar.xz | \ - xzcat | tar xf - && \ - ln -s arduino-${ARDUINO_VERSION} arduino RUN curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | \ sh -RUN /usr/local/bin/arduino-cli core install arduino:avr +RUN ARDUINO_DIRECTORIES_DATA=/arduino-cli/data /bin/arduino-cli config init +RUN ARDUINO_DIRECTORIES_DATA=/arduino-cli/data /bin/arduino-cli update +RUN ARDUINO_DIRECTORIES_DATA=/arduino-cli/data /bin/arduino-cli core install arduino:avr COPY docker-entrypoint.sh /usr/local/bin/entrypoint @@ -24,10 +20,9 @@ COPY docker-entrypoint.sh /usr/local/bin/entrypoint VOLUME ["/kaleidoscope", \ "/kaleidoscope-src", \ "/kaleidoscope-persist", \ - "/kaleidoscope/hardware/keyboardio/avr/libraries/Kaleidoscope/testing/googletest/build", \ - "/kaleidoscope/hardware/keyboardio/avr/libraries/Kaleidoscope/_build"] + "/kaleidoscope/testing/googletest/build", \ + "/kaleidoscope/_build"] -ENV BOARD_HARDWARE_PATH "/kaleidoscope/hardware" ENV KALEIDOSCOPE_TEMP_PATH "/kaleidoscope-persist/temp" diff --git a/etc/docker-entrypoint.sh b/etc/docker-entrypoint.sh index 557b59db..4a06b284 100755 --- a/etc/docker-entrypoint.sh +++ b/etc/docker-entrypoint.sh @@ -1,20 +1,24 @@ #! /bin/bash set -e -install -d /kaleidoscope/hardware/keyboardio \ - /kaleidoscope/hardware/keyboardio/avr/libraries/Kaleidoscope \ +install -d /kaleidoscope/ \ + /kaleidoscope/.arduino/user/hardware/keyboardio \ /kaleidoscope-persist/temp \ /kaleidoscope-persist/ccache/cache -echo "Syncing the bundle..." -tar xf /kaleidoscope-src/bundle.tar -C /kaleidoscope/hardware/keyboardio echo "Syncing Kaleidoscope..." -tar xf /kaleidoscope-src/kaleidoscope.tar -C /kaleidoscope/hardware/keyboardio/avr/libraries/Kaleidoscope +tar xf /kaleidoscope-src/kaleidoscope.tar -C /kaleidoscope/ + +echo "Syncing the bundle..." +tar xf /kaleidoscope-src/bundle.tar -C /kaleidoscope/.arduino/user/hardware/keyboardio + +rm -f /kaleidoscope/.arduino/user/hardware/keyboardio/avr/libraries/Kaleidoscope +ln -s /kaleidoscope /kaleidoscope/.arduino/user/hardware/keyboardio/avr/libraries/Kaleidoscope -ln -s /kaleidoscope/hardware/keyboardio/virtual/libraries/Kaleidoscope \ - /kaleidoscope/hardware/keyboardio/avr/libraries/Kaleidoscope -cd /kaleidoscope/hardware/keyboardio/avr/libraries/Kaleidoscope +cd /kaleidoscope/ +export ARDUINO_DIRECTORIES_DATA=/arduino-cli/data +export KALEIDOSCOPE_CCACHE=1 /bin/bash -c "$*"