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 <jesse@keyboard.io>
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/926/head
Gergely Nagy 4 years ago
parent 5d59552403
commit ba7b496af5
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

3
.gitignore vendored

@ -1,4 +1,5 @@
*~
/.docker_xfer
.#*
/output/
/examples/*/output/
@ -7,4 +8,4 @@
/docs/doxyoutput
/docs/api
/_build/
/results/
/results/

@ -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

@ -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/*

@ -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 "$*"
Loading…
Cancel
Save