Skip to content

Commit efafa4b

Browse files
committed
docs(lib-builder): Add docker image documentation
1 parent e8e251a commit efafa4b

File tree

2 files changed

+100
-2
lines changed

2 files changed

+100
-2
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,7 @@ libraries/Insights/examples/*/*.ino.zip
5050
!.vale/styles/Vocab/
5151
.vale/styles/Vocab/*
5252
!.vale/styles/Vocab/Espressif/
53+
54+
# Ignore Lib Builder Docker run scripts
55+
/run.sh
56+
/run.ps1

docs/en/lib_builder.rst

+96-2
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,10 @@ This build command will build for the ESP32-S3 target. You can specify other tar
152152

153153
* esp32
154154
* esp32s2
155-
* esp32c3
156155
* esp32s3
156+
* esp32c2
157+
* esp32c3
158+
* esp32h2
157159

158160
Set Build Type
159161
^^^^^^^^^^^^^^
@@ -169,11 +171,103 @@ Set the build type. ex. 'build' to build the project and prepare for uploading t
169171
Additional Configuration
170172
^^^^^^^^^^^^^^^^^^^^^^^^
171173

172-
Specify additional configs to be applied. ex. 'qio 80m' to compile for QIO Flash@80MHz. Requires -b
174+
Specify additional configs to be applied. ex. 'qio 80m' to compile for QIO Flash@80MHz.
173175

174176
.. note:: This command requires the ``-b`` to work properly.
175177

176178

177179
.. code-block:: bash
178180
179181
./build.sh -t esp32 -b idf_libs qio 80m
182+
183+
Docker Image
184+
------------
185+
186+
You can use a docker image that has all the dependencies installed to build the libraries. The image is based on Ubuntu 22.04 and contains:
187+
188+
* Common utilities such as ``git``, ``wget`` and ``curl``;
189+
* Python 3.9 or newer;
190+
* A copy of a specific version of Lib Builder. See below for information about versions;
191+
* All dependencies required to build the libraries.
192+
193+
Tags
194+
****
195+
196+
Multiple tags of this image are maintained:
197+
198+
- ``latest``: tracks ``master`` branch of the Lib Builder
199+
- ``vX.Y``: corresponds to Lib Builder release ``vX.Y``
200+
- ``release-vX.Y``: tracks ``release/vX.Y`` branch of the Lib Builder
201+
202+
.. note::
203+
Versions of Lib Builder released before this feature was introduced do not have corresponding Docker image versions.
204+
You can check the up-to-date list of available tags at https://hub.docker.com/r/espressif/esp32-arduino-lib-builder/tags.
205+
206+
Usage
207+
*****
208+
209+
Before using the ``espressif/esp32-arduino-lib-builder`` Docker image locally, make sure you have Docker installed.
210+
Follow the instructions at https://docs.docker.com/install/, if it is not installed yet.
211+
212+
If using the image in a CI environment, consult the documentation of your CI service on how to specify the image used for the build process.
213+
214+
Building the Libraries
215+
^^^^^^^^^^^^^^^^^^^^^^
216+
217+
You have two options to run the Docker image to build the libraries. Manually or using the provided run script.
218+
219+
To run the Docker image manually, use the following command from the root of the ``arduino-esp32`` repository:
220+
221+
.. code-block:: bash
222+
docker run -it -v $PWD:/arduino-esp32 -e TERM=xterm-256color espressif/esp32-arduino-lib-builder
223+
224+
This will start the Lib Builder UI for compiling the libraries. The above command explained:
225+
226+
- ``docker run``: Runs a Docker image. It is a shorter form of the command ``docker container run``.
227+
- ``-it``: Allocates a pseudo-TTY and starts an interactive shell in the container.
228+
- ``-v $PWD:/project``: Mounts the current directory on the host (``$PWD``) as ``/arduino-esp32`` directory in the container.
229+
- ``-e TERM=xterm-256color``: Set the terminal type to ``xterm-256color``. This is required if you want the colors to be displayed correctly.
230+
- ``espressif/esp32-arduino-lib-builder``: uses Docker image ``espressif/esp32-arduino-lib-builder`` with tag ``latest``. The ``latest`` tag is implicitly added by Docker when no tag is specified.
231+
232+
To run the Docker image using the provided run script it will depend on the host OS.
233+
Use the following command from the root of the ``arduino-esp32`` repository to execute the image in a Linux or macOS environment:
234+
235+
.. code-block:: bash
236+
237+
curl -LJO https://raw.githubusercontent.com/espressif/esp32-arduino-lib-builder/master/tools/docker/run.sh
238+
chmod +x run.sh
239+
./run.sh $PWD
240+
241+
For Windows, use the following command in PowerShell from the root of the ``arduino-esp32`` repository:
242+
243+
.. code-block:: powershell
244+
245+
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/espressif/esp32-arduino-lib-builder/master/tools/docker/run.ps1" -OutFile "run.ps1"
246+
.\run.ps1 $PWD
247+
248+
.. warning::
249+
It is always a good practice to understand what the script does before running it.
250+
Make sure to analyze the content of the script to ensure it is safe to run and won't cause any harm to your system.
251+
252+
Building Custom Images
253+
**********************
254+
255+
To build a custom Docker image, you need to clone the Lib Builder repository and use the provided Dockerfile in the Lib Builder repository. The Dockerfile is located in the ``tools/docker`` directory.
256+
257+
The `Docker file in the Lib Builder repository <https://github.com/espressif/esp32-arduino-lib-builder/blob/master/tools/docker/Dockerfile>`_ provides several build arguments which can be used to customize the Docker image:
258+
259+
- ``LIBBUILDER_CLONE_URL``: URL of the repository to clone Lib Builder from. Can be set to a custom URL when working with a fork of Lib Builder. The default is ``https://github.com/espressif/esp32-arduino-lib-builder.git``;
260+
- ``LIBBUILDER_CLONE_BRANCH_OR_TAG``: Name of a git branch or tag used when cloning Lib Builder. This value is passed to the ``git clone`` command using the ``--branch`` argument. The default is ``master``;
261+
- ``LIBBUILDER_CHECKOUT_REF``: If this argument is set to a non-empty value, ``git checkout $LIBBUILDER_CHECKOUT_REF`` command performs after cloning. This argument can be set to the SHA of the specific commit to check out, for example, if some specific commit on a release branch is desired;
262+
- ``LIBBUILDER_CLONE_SHALLOW``: If this argument is set to a non-empty value, ``--depth=1 --shallow-submodules`` arguments are used when performing ``git clone``. Depth can be customized using ``LIBBUILDER_CLONE_SHALLOW_DEPTH``. Doing a shallow clone significantly reduces the amount of data downloaded and the size of the resulting Docker image. However, if switching to a different branch in such a "shallow" repository is necessary, an additional ``git fetch origin <branch>`` command must be executed first;
263+
- ``LIBBUILDER_CLONE_SHALLOW_DEPTH``: This argument specifies the depth value to use when doing a shallow clone. If not set, ``--depth=1`` will be used. This argument has effect only if ``LIBBUILDER_CLONE_SHALLOW`` is used. Use this argument if you are building a Docker image for a branch, and the image has to contain the latest tag on that branch. To determine the required depth, run ``git describe`` for the given branch and note the offset number. Increment it by 1, then use it as the value of this argument. The resulting image will contain the latest tag on the branch, and consequently ``git describe`` command inside the Docker image will work as expected;
264+
265+
To use these arguments, pass them via the ``--build-arg`` command line option. For example, the following command builds a Docker image with a shallow clone of Lib Builder from a specific repository and branch:
266+
267+
.. code-block:: bash
268+
269+
docker buildx build -t lib-builder-custom:master \
270+
--build-arg LIBBUILDER_CLONE_BRANCH_OR_TAG=master \
271+
--build-arg LIBBUILDER_CLONE_SHALLOW=1 \
272+
--build-arg LIBBUILDER_CLONE_URL=https://github.com/espressif/esp32-arduino-lib-builder \
273+
tools/docker

0 commit comments

Comments
 (0)