forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Tools for setup-free CircuitPython builds #9349
Open
timchinowsky
wants to merge
8
commits into
adafruit:main
Choose a base branch
from
timchinowsky:docker-build
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+94
−0
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
92b9df0
add docker-build
timchinowsky 382ade1
Merge branch 'adafruit:main' into docker-build
timchinowsky 539d02f
fix README
timchinowsky 0dba0e4
update README
timchinowsky d9bef70
update README
timchinowsky 2ce8449
Clean up Dockerfile
timchinowsky 965707e
fix permissions
timchinowsky bb190a2
Merge branch 'adafruit:main' into docker-build
timchinowsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
FROM ubuntu:24.04 as build | ||
|
||
ARG ARM_TOOLCHAIN_URL=https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/ | ||
|
||
ARG ARM_TOOLCHAIN_FILE=arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.tar.gz | ||
|
||
ARG ARM_TOOLCHAIN_DIR=arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi | ||
|
||
ARG TOOLS_DIR=/tools | ||
|
||
ARG DOWNLOAD_DIR=${TOOLS_DIR}/bin | ||
|
||
RUN apt-get update && apt-get install -y build-essential software-properties-common git git-lfs gettext cmake mtools wget curl which | ||
|
||
RUN mkdir -p ${DOWNLOAD_DIR} && cd ${DOWNLOAD_DIR} && curl -LO ${ARM_TOOLCHAIN_URL}/${ARM_TOOLCHAIN_FILE} | ||
|
||
RUN cd ${DOWNLOAD_DIR} && pwd && tar -xf ${ARM_TOOLCHAIN_FILE} && rm ${ARM_TOOLCHAIN_FILE} | ||
|
||
ENV PATH="${PATH}:${DOWNLOAD_DIR}/${ARM_TOOLCHAIN_DIR}/bin" | ||
|
||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -y | sh | ||
|
||
RUN apt-get install -y git wget flex bison gperf python3 python3-pip python3-venv cmake ninja-build | ||
|
||
RUN apt-get install -y ccache libffi-dev libssl-dev dfu-util libusb-1.0-0 python-is-python3 | ||
|
||
ENV IDF_TOOLS_PATH=${TOOLS_DIR}/.espressif | ||
|
||
ENV IDF_PATH=${TOOLS_DIR}/esp/esp-idf | ||
|
||
RUN mkdir -p ${TOOLS_DIR}/esp && cd ${TOOLS_DIR}/esp && git clone -b v5.2.2 --recursive https://github.com/espressif/esp-idf.git | ||
|
||
RUN cd ${TOOLS_DIR}/esp/esp-idf && ./install.sh all | ||
|
||
RUN curl -LO https://raw.githubusercontent.com/adafruit/circuitpython/main/requirements-dev.txt | ||
|
||
RUN curl -LO https://raw.githubusercontent.com/adafruit/circuitpython/main/requirements-doc.txt | ||
|
||
RUN . ${TOOLS_DIR}/esp/esp-idf/export.sh && pip3 install --upgrade -r requirements-dev.txt && \ | ||
pip3 install --upgrade -r requirements-doc.txt | ||
|
||
COPY build.sh ${TOOLS_DIR} | ||
|
||
RUN chmod -R a=u ${TOOLS_DIR} | ||
|
||
ENTRYPOINT ["/bin/bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Building CircuitPython with Docker | ||
|
||
On a Linux machine with `docker` installed, an executable for any supported CircuitPython board can be built without setup by invoking the command `tools/docker-build/build <port> <board-name> <option>` from the CircuitPython root directory. For example, if the CircuitPython repo is located at `~/circuitpython` the commands | ||
|
||
```bash | ||
cd ~/circuitpython | ||
tools/docker-build/build espressif adafruit_feather_esp32s2_reverse_tft | ||
tools/docker-build/build raspberrypi waveshare_rp2040_zero | ||
tools/docker-build/build atmel-samd grandcentral_m4_express DEBUG=1 TRANSLATION=es | ||
``` | ||
|
||
will build executables for a Feather ESP32S2 board, a Waveshare RP2040 board and an Adafruit Grand Central M4 Express board, and the Grand Central build will include debugging information and Spanish localization. | ||
|
||
## Building a new Docker image | ||
|
||
The `build` script uses tools built into a container image pulled from a public Docker Hub repository. If you like, you can build your own image from the `Dockerfile` in this directory with the command | ||
|
||
```bash | ||
docker build -t <name> . | ||
``` | ||
|
||
Where <name> is the name that will be applied to the image. If you then change the value of `$LOCAL_IMAGE` in the `build` script to match <name>, `build` will use the new image for building CircuitPython. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
REMOTE_IMAGE="timchinowsky/build_circuitpython" | ||
|
||
LOCAL_IMAGE=$REMOTE_IMAGE | ||
|
||
make fetch-all-submodules | ||
|
||
docker pull $REMOTE_IMAGE | ||
|
||
docker run --user $UID:$(id -g) -it -v .:/circuitpython $LOCAL_IMAGE /tools/build.sh "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
git config --global --add safe.directory /circuitpython | ||
|
||
git config --global --add safe.directory /circuitpython/ports/espressif/esp-idf | ||
|
||
cd /circuitpython | ||
|
||
make fetch-tags | ||
|
||
. /tools/esp/esp-idf/export.sh | ||
|
||
cd /circuitpython/ports/$1 | ||
|
||
make BOARD=${@:2} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gets the requirements files from the tip of main, but I think you want to get them from the repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
Dockerfile
is only used to build the image. I'm including it so that folks can see what it is doing (basically the same steps you would need to do on the command line to install the tools) and be empowered to create their own images.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean the repo that CP is being built from? Can't do that because the image is given access to that repo at runtime, but the requirements need to be available at image build time so that the python built into the image can be configured. If you wanted to do it the other way, you'd need to have python pull in the requirements every time it is asked to build CP.