Skip to content

Commit 78b6946

Browse files
committed
Merge branch 'feature/docker' into feature/config_ui
2 parents ed73ad9 + f9e16c8 commit 78b6946

File tree

3 files changed

+166
-0
lines changed

3 files changed

+166
-0
lines changed

Diff for: tools/docker/Dockerfile

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
FROM ubuntu:22.04
2+
3+
# switch to root, let the entrypoint drop back to host user
4+
USER root
5+
6+
ARG DEBIAN_FRONTEND=noninteractive
7+
8+
RUN : \
9+
&& apt-get update \
10+
&& apt-get install -y --no-install-recommends \
11+
bison \
12+
ccache \
13+
cmake \
14+
curl \
15+
flex \
16+
git \
17+
gperf \
18+
jq \
19+
libncurses-dev \
20+
libssl-dev \
21+
libusb-1.0 \
22+
ninja-build \
23+
patch \
24+
python3 \
25+
python3-click \
26+
python3-cryptography \
27+
python3-future \
28+
python3-pip \
29+
python3-pyelftools \
30+
python3-pyparsing \
31+
python3-serial \
32+
python3-setuptools \
33+
python3-textual \
34+
python3-venv \
35+
wget \
36+
&& pip install --upgrade pip \
37+
&& apt-get autoremove -y \
38+
&& rm -rf /var/lib/apt/lists/* \
39+
&& :
40+
41+
# install gosu for a better su+exec command
42+
ARG GOSU_VERSION=1.17
43+
RUN dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
44+
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch" \
45+
&& chmod +x /usr/local/bin/gosu \
46+
&& gosu nobody true
47+
48+
# To build the image for a branch or a tag of the lib-builder, pass --build-arg LIBBUILDER_CLONE_BRANCH_OR_TAG=name.
49+
# To build the image with a specific commit ID of lib-builder, pass --build-arg LIBBUILDER_CHECKOUT_REF=commit-id.
50+
# It is possibe to combine both, e.g.:
51+
# LIBBUILDER_CLONE_BRANCH_OR_TAG=release/vX.Y
52+
# LIBBUILDER_CHECKOUT_REF=<some commit on release/vX.Y branch>.
53+
# Use LIBBUILDER_CLONE_SHALLOW=1 to peform shallow clone (i.e. --depth=1 --shallow-submodules)
54+
# Use LIBBUILDER_CLONE_SHALLOW_DEPTH=X to define the depth if LIBBUILDER_CLONE_SHALLOW is used (i.e. --depth=X)
55+
56+
ARG LIBBUILDER_CLONE_URL=https://github.com/espressif/esp32-arduino-lib-builder
57+
ARG LIBBUILDER_CLONE_BRANCH_OR_TAG=master
58+
ARG LIBBUILDER_CHECKOUT_REF=
59+
ARG LIBBUILDER_CLONE_SHALLOW=
60+
ARG LIBBUILDER_CLONE_SHALLOW_DEPTH=1
61+
ARG LIBBUILDER_TARGETS=all
62+
63+
ENV LIBBUILDER_PATH=/opt/esp/lib-builder
64+
ENV ARDUINO_PATH=/opt/esp/lib-builder/arduino-esp32
65+
# Ccache is installed, enable it by default
66+
ENV IDF_CCACHE_ENABLE=1
67+
68+
RUN echo LIBBUILDER_CHECKOUT_REF=$LIBBUILDER_CHECKOUT_REF LIBBUILDER_CLONE_BRANCH_OR_TAG=$LIBBUILDER_CLONE_BRANCH_OR_TAG && \
69+
git clone --recursive \
70+
${LIBBUILDER_CLONE_SHALLOW:+--depth=${LIBBUILDER_CLONE_SHALLOW_DEPTH} --shallow-submodules} \
71+
${LIBBUILDER_CLONE_BRANCH_OR_TAG:+-b $LIBBUILDER_CLONE_BRANCH_OR_TAG} \
72+
$LIBBUILDER_CLONE_URL $LIBBUILDER_PATH && \
73+
git config --system --add safe.directory $LIBBUILDER_PATH && \
74+
if [ -n "$LIBBUILDER_CHECKOUT_REF" ]; then \
75+
cd $LIBBUILDER_PATH && \
76+
if [ -n "$LIBBUILDER_CLONE_SHALLOW" ]; then \
77+
git fetch origin --depth=${LIBBUILDER_CLONE_SHALLOW_DEPTH} --recurse-submodules ${LIBBUILDER_CHECKOUT_REF}; \
78+
fi && \
79+
git checkout $LIBBUILDER_CHECKOUT_REF && \
80+
git submodule update --init --recursive; \
81+
fi
82+
83+
COPY entrypoint.sh $LIBBUILDER_PATH/entrypoint.sh
84+
85+
WORKDIR /opt/esp/lib-builder
86+
ENTRYPOINT [ "/opt/esp/lib-builder/entrypoint.sh" ]
87+
CMD [ "bash" ]

Diff for: tools/docker/entrypoint.sh

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# LIBBUILDER_GIT_SAFE_DIR has the same format as system PATH environment variable.
5+
# All path specified in LIBBUILDER_GIT_SAFE_DIR will be added to user's
6+
# global git config as safe.directory paths. For more information
7+
# see git-config manual page.
8+
if [ -n "${LIBBUILDER_GIT_SAFE_DIR+x}" ]
9+
then
10+
echo "Adding following directories into git's safe.directory"
11+
echo "$LIBBUILDER_GIT_SAFE_DIR" | tr ':' '\n' | while read -r dir
12+
do
13+
git config --global --add safe.directory "$dir"
14+
echo " $dir"
15+
done
16+
fi
17+
18+
if [ "$(id -u)" = "0" ] && [ -n "${HOST_UID}" ]; then
19+
groupadd -g ${HOST_UID} host_user
20+
useradd -m -u ${HOST_UID} -g ${HOST_UID} host_user
21+
22+
if [ -d /arduino-esp32 ]; then
23+
chown -R ${HOST_UID}:${HOST_UID} /arduino-esp32
24+
fi
25+
26+
chown -R ${HOST_UID}:${HOST_UID} /opt/esp
27+
28+
# Add call to gosu to drop from root user to host_user
29+
# when running original entrypoint
30+
set -- gosu host_user "$@"
31+
fi
32+
33+
exec "$@"

Diff for: tools/docker/run.sh

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
3+
i=0
4+
NEXT_ARG="false"
5+
ARDUINO_DIR=""
6+
DOCKER_ARGS=()
7+
ORIGINAL_ARGS=("$@")
8+
TRIMMED_ARGS=()
9+
10+
while [ $i -lt ${#ORIGINAL_ARGS[@]} ]; do
11+
arg=${ORIGINAL_ARGS[$i]}
12+
if [ $arg == "-c" ]; then
13+
NEXT_ARG="true"
14+
elif [ $NEXT_ARG == "true" ]; then
15+
ARDUINO_DIR=$arg
16+
NEXT_ARG="false"
17+
else
18+
TRIMMED_ARGS+=($arg)
19+
fi
20+
i=$((i + 1))
21+
done
22+
23+
if [ -n "$ARDUINO_DIR" ]; then
24+
if [ ! -d "$ARDUINO_DIR" ]; then
25+
echo "Arduino directory \"$ARDUINO_DIR\" does not exist"
26+
exit 1
27+
fi
28+
ARDUINO_DIR=$(echo $(cd $ARDUINO_DIR; pwd))
29+
DOCKER_ARGS+=(-v $ARDUINO_DIR:/arduino-esp32)
30+
TRIMMED_ARGS+=(-c /arduino-esp32)
31+
fi
32+
33+
DOCKER_ARGS+=(-e HOST_UID=$UID)
34+
35+
if [ -n "$LIBBUILDER_GIT_SAFE_DIR" ]; then
36+
DOCKER_ARGS+=(-e LIBBUILDER_GIT_SAFE_DIR=$LIBBUILDER_GIT_SAFE_DIR)
37+
fi
38+
39+
if [ "$VERBOSE_OUTPUT" -eq 1 ]; then
40+
echo "Arguments:"
41+
echo "DOCKER_ARGS = ${DOCKER_ARGS[@]}"
42+
echo "TRIMMED_ARGS = ${TRIMMED_ARGS[@]}"
43+
echo "Running: docker run ${DOCKER_ARGS[@]} lucassvaz/esp32-arduino-lib-builder ./build.sh ${TRIMMED_ARGS[@]}"
44+
fi
45+
46+
docker run ${DOCKER_ARGS[@]} lucassvaz/esp32-arduino-lib-builder ./build.sh ${TRIMMED_ARGS[@]}

0 commit comments

Comments
 (0)