Skip to content

Instantly share code, notes, and snippets.

@tve
Created December 14, 2022 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tve/c7c74adc5a3ec93511c634861e7e631d to your computer and use it in GitHub Desktop.
Save tve/c7c74adc5a3ec93511c634861e7e631d to your computer and use it in GitHub Desktop.
Moddable SDK docker
FROM debian:stable-slim
RUN set -ex && \
apt-get update &&\
apt-get install -y bash curl vim
WORKDIR /usr/src
# Install ESP-IDF SDK
RUN apt-get install -y git wget flex bison gperf cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0
RUN apt-get install -y python3 python3-venv python3-pip python-is-python3
RUN cd /usr/src && git clone -b v4.4.3 --recursive https://github.com/espressif/esp-idf.git
RUN cd /usr/src/esp-idf &&\
export IDF_TOOLS_PATH=/usr/src/idf-tools &&\
mkdir -p $IDF_TOOLS_PATH &&\
./install.sh esp32,esp32s3
# Install Moddable SDK
RUN apt-get install -y gcc git wget make libncurses-dev flex bison gperf libgtk-3-dev udev
RUN cd /usr/src && git clone https://github.com/Moddable-OpenSource/moddable
RUN export MODDABLE=/usr/src/moddable &&\
cd $MODDABLE/build/makefiles/lin &&\
make &&\
mv $MODDABLE/build $MODDABLE/build-orig
COPY env.sh .
#! /usr/bin/env bash
export MODDABLE=/usr/src/moddable
export PATH=$PATH:$MODDABLE/build/bin/lin/release
export IDF_PATH=/usr/src/esp-idf
export IDF_TOOLS_PATH=/usr/src/idf-tools
. $IDF_PATH/export.sh
cp -au moddable/build-orig/* moddable/build
#! /usr/bin/env bash
CMD="source env.sh >/dev/null 2>&1"
CMD="$CMD && cd /data && $@"
#CMD="$CMD; mcconfig $@"
#CMD="$CMD; bash"
mkdir -p .build
# map serial devices into the container
SER=""
shopt -s nullglob
for s in /dev/ttyACM* /dev/ttyUSB*; do
echo "Adding $s to container"
SER="$SER --device $s"
if ! [[ -r $s ]]; then
echo "Using sudo to make $s world-accessible"
sudo chmod 777 $s
fi
done
uid=$(id -u)
# mount the current dir with the source code in /data
# mount .build into $MODDABLE/build in the container 'cause moddable writes into its source
# tree (ugly bad practice)
# mount $HOME/.cache into /.cache in the container 'cause esp-idf caches some stuff there
# map the serial ports into the container
# run as the current user $uid and use host networking to access xsbug
sudo docker run --rm -ti \
-e TZ=America/Los_Angeles \
-v $PWD:/data \
-v $PWD/.build:/usr/src/moddable/build \
-v $HOME/.cache:/.cache \
$SER \
-u $uid \
--network host \
--entrypoint bash \
--name moddable \
moddable \
-c "$CMD"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment