From 5d5955240320c7c88e7abe190883071931c32db0 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 12 Oct 2020 21:02:10 -0700 Subject: [PATCH 1/2] Add a note about how we should offer at least a 60 day deprecation period for APIs --- docs/UPGRADING.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index 4bd0d905..d05a0c7f 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -25,6 +25,10 @@ If any of this does not make sense to you, or you have trouble updating your .in # Upgrade notes +As a matter of policy, we try hard to give you at least 60 days notice before we permanently remove or break +any API we've included in a release. Typically, this means that any code that uses the old API will emit a warning when compiled with a newer version of Kaleidoscope. In all cases, this document should explain how to update your code to use the new API. + + ## New features ### New device API From ba7b496af5fb6c7e178eab37bd3449d1589e6e8d Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Mon, 12 Oct 2020 12:12:28 +0200 Subject: [PATCH 2/2] Rework our Docker config for performance * never try to write anything to the host's disks * read as little as possible from the host's disks * keep source in ram * cache build artifacts and intermediate content persistently Most of these hacks are only necessary because Docker disk performance on macOS is...not performant Signed-off-by: Jesse Vincent Signed-off-by: Gergely Nagy --- .gitignore | 3 ++- bin/run-docker | 29 +++++++++++++++++++++++++---- etc/Dockerfile | 30 ++++++++++++++++++++++++------ etc/docker-entrypoint.sh | 20 ++++++++++++++++++++ 4 files changed, 71 insertions(+), 11 deletions(-) create mode 100755 etc/docker-entrypoint.sh diff --git a/.gitignore b/.gitignore index 41e3da52..710ed307 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *~ +/.docker_xfer .#* /output/ /examples/*/output/ @@ -7,4 +8,4 @@ /docs/doxyoutput /docs/api /_build/ -/results/ \ No newline at end of file +/results/ diff --git a/bin/run-docker b/bin/run-docker index 84cfbb38..ead78f1d 100755 --- a/bin/run-docker +++ b/bin/run-docker @@ -8,12 +8,33 @@ ARDUINO_LOCAL_LIB_PATH="${ARDUINO_LOCAL_LIB_PATH:-${HOME}/Arduino}" 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 fi BOARD_HARDWARE_PATH="${BOARD_HARDWARE_PATH:-${ARDUINO_LOCAL_LIB_PATH}/hardware}" -docker build -t kaleidoscope/docker etc +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 \ + . + +(cd "${BOARD_HARDWARE_PATH}/keyboardio" && tar -cf "${XFER_DIR}/bundle.tar" \ + --exclude .git --exclude avr/libraries/Kaleidoscope .) + +echo "Building the docker image..." +docker build -q -t kaleidoscope/docker etc docker run --rm -it \ - -v "${BOARD_HARDWARE_PATH}/keyboardio:/kaleidoscope/hardware/keyboardio" \ - -v "$(pwd):/kaleidoscope/hardware/keyboardio/avr/libraries/Kaleidoscope" \ - kaleidoscope/docker -c "$*" + --tmpfs /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 \ + kaleidoscope/docker "$*" + + +exit 0 diff --git a/etc/Dockerfile b/etc/Dockerfile index 90d07e04..2f587e4a 100644 --- a/etc/Dockerfile +++ b/etc/Dockerfile @@ -1,8 +1,12 @@ -FROM debian:stable-slim +FROM ubuntu:20.04 LABEL maintainer="Keyboard.io, inc" -RUN apt-get -qq update -RUN apt-get -qq install -y xz-utils curl git-core make build-essential libxtst-dev cmake +RUN apt-get -qq update && \ + DEBIAN_FRONTEND=noninteractive \ + apt-get -qq install -y xz-utils curl make build-essential libxtst-dev cmake ccache + +RUN ccache --set-config=cache_dir=/kaleidoscope-persist/ccache/cache + ENV ARDUINO_VERSION "1.8.13" @@ -14,7 +18,21 @@ RUN curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/inst sh RUN /usr/local/bin/arduino-cli core install arduino:avr -VOLUME ["/kaleidoscope/hardware/keyboardio"] + +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"] + ENV BOARD_HARDWARE_PATH "/kaleidoscope/hardware" -WORKDIR /kaleidoscope/hardware/keyboardio/avr/libraries/Kaleidoscope -ENTRYPOINT ["/bin/bash"] +ENV KALEIDOSCOPE_TEMP_PATH "/kaleidoscope-persist/temp" + + +ENTRYPOINT ["/usr/local/bin/entrypoint"] + +# Clean up APT when done. +RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + diff --git a/etc/docker-entrypoint.sh b/etc/docker-entrypoint.sh new file mode 100755 index 00000000..557b59db --- /dev/null +++ b/etc/docker-entrypoint.sh @@ -0,0 +1,20 @@ +#! /bin/bash +set -e + +install -d /kaleidoscope/hardware/keyboardio \ + /kaleidoscope/hardware/keyboardio/avr/libraries/Kaleidoscope \ + /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 + +ln -s /kaleidoscope/hardware/keyboardio/virtual/libraries/Kaleidoscope \ + /kaleidoscope/hardware/keyboardio/avr/libraries/Kaleidoscope + +cd /kaleidoscope/hardware/keyboardio/avr/libraries/Kaleidoscope + +/bin/bash -c "$*"