Skip to content

Add lib-builder docker image #155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
cd6f3bd
Test docker Image
lucasssvaz Feb 8, 2024
a635979
Fix Dockerfile
lucasssvaz Feb 8, 2024
1768d26
Fix file permissions
lucasssvaz Feb 9, 2024
750c991
Fix bugs and add run script
lucasssvaz Feb 10, 2024
a4ee927
Update tools/docker/Dockerfile
lucasssvaz Feb 19, 2024
c93cfec
Add textual to docker image
lucasssvaz Feb 21, 2024
f9e16c8
Reorder
lucasssvaz Feb 22, 2024
ec816df
Fix
lucasssvaz Feb 29, 2024
1e327a2
Test
lucasssvaz Feb 29, 2024
9a74157
Fix
lucasssvaz Feb 29, 2024
be7d72b
Merge branch 'master' into feature/docker
me-no-dev Apr 8, 2024
920e3dd
Merge branch 'master' into feature/docker
lucasssvaz Apr 8, 2024
d87db7d
Add UI checks
lucasssvaz Apr 8, 2024
e98f227
Fix docker image
lucasssvaz Apr 8, 2024
c3c1587
Fix exec in docker
lucasssvaz Apr 8, 2024
69d1573
Move argument
lucasssvaz Apr 8, 2024
74290ef
Add workflow
lucasssvaz Apr 8, 2024
a11164c
Add checks to entrypoint
lucasssvaz Apr 9, 2024
52e00bd
Improvements to Dockerfile
lucasssvaz Apr 9, 2024
c4f4ce3
Test example run scripts
lucasssvaz Apr 9, 2024
36acb43
Fix powershell script
lucasssvaz Apr 9, 2024
1cf54a3
Change parameter name
lucasssvaz Apr 9, 2024
7f79287
Add comment
lucasssvaz Apr 9, 2024
22b8489
Add Readme
lucasssvaz Apr 9, 2024
d0ada4a
Fix comparison
lucasssvaz Apr 9, 2024
16e4611
Remove cache
lucasssvaz Apr 9, 2024
203237d
Fix comment
lucasssvaz Apr 9, 2024
297b88b
Improve permission settings
lucasssvaz Apr 9, 2024
cfe8da7
Add warning
lucasssvaz Apr 9, 2024
a6ae4a6
Update readme
lucasssvaz Apr 9, 2024
c0b622d
Merge branch 'master' into feature/docker
lucasssvaz Apr 9, 2024
671b1b6
Fix repositories
lucasssvaz Apr 9, 2024
ac5225a
Merge branch 'master' into feature/docker
lucasssvaz Apr 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions tools/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
FROM ubuntu:22.04

# switch to root, let the entrypoint drop back to host user
USER root

ARG DEBIAN_FRONTEND=noninteractive

RUN : \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
bison \
ccache \
cmake \
curl \
flex \
git \
gperf \
jq \
libncurses-dev \
libssl-dev \
libusb-1.0 \
ninja-build \
patch \
python3 \
python3-click \
python3-cryptography \
python3-future \
python3-pip \
python3-pyelftools \
python3-pyparsing \
python3-serial \
python3-setuptools \
python3-venv \
wget \
&& pip install --upgrade pip \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* \
&& :

# install gosu for a better su+exec command
ARG GOSU_VERSION=1.17
RUN dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch" \
&& chmod +x /usr/local/bin/gosu \
&& gosu nobody true

# To build the image for a branch or a tag of the lib-builder, pass --build-arg LIBBUILDER_CLONE_BRANCH_OR_TAG=name.
# To build the image with a specific commit ID of lib-builder, pass --build-arg LIBBUILDER_CHECKOUT_REF=commit-id.
# It is possibe to combine both, e.g.:
# LIBBUILDER_CLONE_BRANCH_OR_TAG=release/vX.Y
# LIBBUILDER_CHECKOUT_REF=<some commit on release/vX.Y branch>.
# Use LIBBUILDER_CLONE_SHALLOW=1 to peform shallow clone (i.e. --depth=1 --shallow-submodules)
# Use LIBBUILDER_CLONE_SHALLOW_DEPTH=X to define the depth if LIBBUILDER_CLONE_SHALLOW is used (i.e. --depth=X)
# Use IDF_INSTALL_TARGETS to install tools only for selected chip targets (CSV)

ARG LIBBUILDER_CLONE_URL=https://github.com/espressif/esp32-arduino-lib-builder
ARG LIBBUILDER_CLONE_BRANCH_OR_TAG=master
ARG LIBBUILDER_CHECKOUT_REF=
ARG LIBBUILDER_CLONE_SHALLOW=
ARG LIBBUILDER_CLONE_SHALLOW_DEPTH=1
ARG LIBBUILDER_TARGETS=all

ENV LIBBUILDER_PATH=/opt/esp/lib-builder
ENV ARDUINO_PATH=/opt/esp/lib-builder/arduino-esp32

RUN echo LIBBUILDER_CHECKOUT_REF=$LIBBUILDER_CHECKOUT_REF LIBBUILDER_CLONE_BRANCH_OR_TAG=$LIBBUILDER_CLONE_BRANCH_OR_TAG && \
git clone --recursive \
${LIBBUILDER_CLONE_SHALLOW:+--depth=${LIBBUILDER_CLONE_SHALLOW_DEPTH} --shallow-submodules} \
${LIBBUILDER_CLONE_BRANCH_OR_TAG:+-b $LIBBUILDER_CLONE_BRANCH_OR_TAG} \
$LIBBUILDER_CLONE_URL $LIBBUILDER_PATH && \
git config --system --add safe.directory $LIBBUILDER_PATH && \
if [ -n "$LIBBUILDER_CHECKOUT_REF" ]; then \
cd $LIBBUILDER_PATH && \
if [ -n "$LIBBUILDER_CLONE_SHALLOW" ]; then \
git fetch origin --depth=${LIBBUILDER_CLONE_SHALLOW_DEPTH} --recurse-submodules ${LIBBUILDER_CHECKOUT_REF}; \
fi && \
git checkout $LIBBUILDER_CHECKOUT_REF && \
git submodule update --init --recursive; \
fi

COPY entrypoint.sh $LIBBUILDER_PATH/entrypoint.sh

# Ccache is installed, enable it by default
ENV IDF_CCACHE_ENABLE=1

WORKDIR /opt/esp/lib-builder
ENTRYPOINT [ "/opt/esp/lib-builder/entrypoint.sh" ]
CMD [ "bash" ]
33 changes: 33 additions & 0 deletions tools/docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -e

# LIBBUILDER_GIT_SAFE_DIR has the same format as system PATH environment variable.
# All path specified in LIBBUILDER_GIT_SAFE_DIR will be added to user's
# global git config as safe.directory paths. For more information
# see git-config manual page.
if [ -n "${LIBBUILDER_GIT_SAFE_DIR+x}" ]
then
echo "Adding following directories into git's safe.directory"
echo "$LIBBUILDER_GIT_SAFE_DIR" | tr ':' '\n' | while read -r dir
do
git config --global --add safe.directory "$dir"
echo " $dir"
done
fi

if [ "$(id -u)" = "0" ] && [ -n "${HOST_UID}" ]; then
groupadd -g ${HOST_UID} host_user
useradd -m -u ${HOST_UID} -g ${HOST_UID} host_user

if [ -d /arduino-esp32 ]; then
chown -R ${HOST_UID}:${HOST_UID} /arduino-esp32
fi

chown -R ${HOST_UID}:${HOST_UID} /opt/esp

# Add call to gosu to drop from root user to host_user
# when running original entrypoint
set -- gosu host_user "$@"
fi

exec "$@"
46 changes: 46 additions & 0 deletions tools/docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash

i=0
NEXT_ARG="false"
ARDUINO_DIR=""
DOCKER_ARGS=()
ORIGINAL_ARGS=("$@")
TRIMMED_ARGS=()

while [ $i -lt ${#ORIGINAL_ARGS[@]} ]; do
arg=${ORIGINAL_ARGS[$i]}
if [ $arg == "-c" ]; then
NEXT_ARG="true"
elif [ $NEXT_ARG == "true" ]; then
ARDUINO_DIR=$arg
NEXT_ARG="false"
else
TRIMMED_ARGS+=($arg)
fi
i=$((i + 1))
done

if [ -n "$ARDUINO_DIR" ]; then
if [ ! -d "$ARDUINO_DIR" ]; then
echo "Arduino directory \"$ARDUINO_DIR\" does not exist"
exit 1
fi
ARDUINO_DIR=$(echo $(cd $ARDUINO_DIR; pwd))
DOCKER_ARGS+=(-v $ARDUINO_DIR:/arduino-esp32)
TRIMMED_ARGS+=(-c /arduino-esp32)
fi

DOCKER_ARGS+=(-e HOST_UID=$UID)

if [ -n "$LIBBUILDER_GIT_SAFE_DIR" ]; then
DOCKER_ARGS+=(-e LIBBUILDER_GIT_SAFE_DIR=$LIBBUILDER_GIT_SAFE_DIR)
fi

if [ "$VERBOSE_OUTPUT" -eq 1 ]; then
echo "Arguments:"
echo "DOCKER_ARGS = ${DOCKER_ARGS[@]}"
echo "TRIMMED_ARGS = ${TRIMMED_ARGS[@]}"
echo "Running: docker run ${DOCKER_ARGS[@]} lucassvaz/esp32-arduino-lib-builder ./build.sh ${TRIMMED_ARGS[@]}"
fi

docker run ${DOCKER_ARGS[@]} lucassvaz/esp32-arduino-lib-builder ./build.sh ${TRIMMED_ARGS[@]}