|
3 | 3 | # This container includes all dependencies for TFLM CI checks and is |
4 | 4 | # recommended for local debugging to ensure a consistent environment. |
5 | 5 | # |
6 | | -# * Pull a prebuilt image: |
7 | | -# See all versions: https://github.com/users/TFLM-bot/packages/container/tflm-ci/versions |
| 6 | +# === Usage === |
| 7 | +# |
| 8 | +# --- Pull a prebuilt image --- |
| 9 | +# See all versions: https://github.com/users/TFLM-bot/packages/container/tflm-ci/versions |
8 | 10 | # docker pull ghcr.io/tflm-bot/tflm-ci:<version> |
9 | 11 | # |
10 | | -# * Build locally: |
11 | | -# (Run from the root of the TFLM repository) |
| 12 | +# --- Build locally --- |
| 13 | +# (Run from the root of the TFLM repository) |
12 | 14 | # docker build -f ci/Dockerfile.micro -t tflm-ci . |
13 | 15 | # |
14 | | -# * Build and upload to GHCR.IO: |
15 | | -# (Run from the root of the TFLM repository) |
16 | | -# (Update the TFLM_CI_VERSION variable below to your target version) |
17 | | -# export TFLM_CI_VERSION=0.6.3 |
| 16 | +# --- Build and upload to GHCR.IO --- |
| 17 | +# (Run from the root of the TFLM repository) |
| 18 | +# export TFLM_CI_VERSION=0.6.4 |
18 | 19 | # docker build -f ci/Dockerfile.micro -t ghcr.io/tflm-bot/tflm-ci:$TFLM_CI_VERSION . |
19 | 20 | # docker push ghcr.io/tflm-bot/tflm-ci:$TFLM_CI_VERSION |
20 | | -# (And you need to update github workflows to use this version.) |
21 | 21 | # |
22 | | -# * Run locally for debugging: |
23 | | -# (Mounts local repo and opens a shell) |
24 | | -# (Run from the root of the TFLM repository) |
| 22 | +# --- Run locally for debugging --- |
| 23 | +# (Mounts local repo and opens a shell) |
| 24 | +# (Run from the root of the TFLM repository) |
25 | 25 | # docker run -it --rm -v $(pwd):/opt/tflm -w /opt/tflm tflm-ci /bin/bash |
| 26 | +# |
26 | 27 |
|
27 | | -# Use a prebuilt Python image instead of base Ubuntu to speed up the build process, |
28 | | -# since it has all the build dependencies we need for Micro and downloads much faster |
29 | | -# than the install process. |
30 | | - |
31 | | -# Using a multistage build so that the build tools required for stage 1 don't make the |
32 | | -# CI container unnecessarily large. |
33 | | -FROM python:3.10-bookworm AS qemu_builder |
34 | | -RUN apt-get update |
35 | | - |
36 | | -RUN apt-get install -y ninja-build wget xz-utils |
37 | | -RUN apt-get install -y libglib2.0-dev |
38 | | -RUN apt-get install -y build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev |
39 | | - |
40 | | -COPY ci/install_qemu.sh ./ |
41 | | -# Installs all built files into /qemu_install rather than /usr/local default. |
42 | | -RUN ./install_qemu.sh /tmp/qemu_install |
43 | | - |
44 | | -# This stage is the final CI container. |
45 | | -FROM python:3.10-bookworm AS tflm-ci |
46 | | - |
47 | | -RUN apt-get update |
48 | | - |
49 | | -RUN apt-get install -y zip xxd sudo |
50 | | - |
51 | | -RUN apt install -y lsb-release wget software-properties-common gnupg |
52 | | -RUN wget https://apt.llvm.org/llvm.sh |
53 | | -RUN chmod +x llvm.sh |
54 | | -RUN ./llvm.sh 21 |
55 | | -RUN ln -s /usr/bin/clang-21 /usr/bin/clang |
56 | | -RUN ln -s /usr/bin/clang++-21 /usr/bin/clang++ |
57 | | - |
58 | | -RUN apt-get install clang-format-21 |
59 | | -RUN ln -s /usr/bin/clang-format-21 /usr/bin/clang-format |
60 | | - |
61 | | -# Needed when using the Dockerfile locally. |
62 | | -RUN git config --global --add safe.directory /opt/tflm |
63 | | - |
64 | | -# Needed when the docker container is used with GitHub actions. |
65 | | -RUN git config --global --add safe.directory /github/workspace |
66 | | - |
67 | | -# Install yapf to check for Python formatting as part of the TFLM continuous |
68 | | -# integration. |
69 | | -RUN pip install yapf==0.40.2 |
70 | | - |
71 | | -# Pillow was added first for the C array generation as a result of the following |
72 | | -# PRs: |
73 | | -# https://github.com/tensorflow/tflite-micro/pull/337 |
74 | | -# https://github.com/tensorflow/tflite-micro/pull/410 |
75 | | -RUN pip install Pillow |
76 | | - |
77 | | -# necessary bits for create_size_log scripts |
78 | | -RUN pip install pandas |
79 | | -RUN pip install matplotlib |
80 | | -RUN pip install six |
81 | | - |
82 | | -# Install Renode test dependencies |
83 | | -RUN pip install pyyaml requests psutil robotframework==4.0.1 |
84 | | - |
85 | | -# Install QEMU from build container qemu_builder into tflm-ci container. |
86 | | -# We're using a two stage build to keep the CI container smaller. |
87 | | -WORKDIR /usr/local |
88 | | -# Merge built files into /usr/local so that the path is already setup. |
89 | | -COPY --from=qemu_builder /tmp/qemu_install/. . |
90 | | - |
| 28 | +# Use a prebuilt Python image to speed up the build process. |
| 29 | +FROM python:3.10-bookworm |
| 30 | + |
| 31 | +# Install all required system dependencies |
| 32 | +RUN apt-get update && apt-get install -y \ |
| 33 | + gnupg \ |
| 34 | + lsb-release \ |
| 35 | + qemu-system-arm \ |
| 36 | + software-properties-common \ |
| 37 | + sudo \ |
| 38 | + wget \ |
| 39 | + xxd \ |
| 40 | + zip \ |
| 41 | + && apt-get clean \ |
| 42 | + && rm -rf /var/lib/apt/lists/* |
| 43 | + |
| 44 | +# Install LLVM/Clang and create symlinks |
| 45 | +RUN wget https://apt.llvm.org/llvm.sh \ |
| 46 | + && chmod +x llvm.sh \ |
| 47 | + && ./llvm.sh 21 \ |
| 48 | + && rm llvm.sh \ |
| 49 | + && apt-get update && apt-get install -y clang-21 clang++-21 clang-format-21 \ |
| 50 | + && ln -s /usr/bin/clang-21 /usr/bin/clang \ |
| 51 | + && ln -s /usr/bin/clang++-21 /usr/bin/clang++ \ |
| 52 | + && ln -s /usr/bin/clang-format-21 /usr/bin/clang-format \ |
| 53 | + && apt-get clean \ |
| 54 | + && rm -rf /var/lib/apt/lists/* |
| 55 | + |
| 56 | +# Install all Python dependencies |
| 57 | +# - yapf to check for Python formatting |
| 58 | +# - Pillow was added first for the C array generation |
| 59 | +# - pandas, matplotlib, and six for create_size_log scripts |
| 60 | +# - pyyaml, requests, psutil, and robotframework for Renode test |
| 61 | +RUN pip install --no-cache-dir --upgrade pip && \ |
| 62 | + pip install --no-cache-dir \ |
| 63 | + matplotlib \ |
| 64 | + pandas \ |
| 65 | + Pillow \ |
| 66 | + psutil \ |
| 67 | + pyyaml \ |
| 68 | + requests \ |
| 69 | + robotframework==4.0.1 \ |
| 70 | + six \ |
| 71 | + yapf==0.40.2 |
| 72 | + |
| 73 | +# Copy and run install scripts, then clean them up |
91 | 74 | WORKDIR / |
92 | 75 | COPY ci/*.sh /install/ |
93 | | -RUN /install/install_bazelisk.sh |
94 | | -RUN /install/install_buildifier.sh |
| 76 | +RUN /install/install_bazelisk.sh && \ |
| 77 | + /install/install_buildifier.sh && \ |
| 78 | + rm -rf /install |
| 79 | + |
| 80 | +# Configure git safe directories |
| 81 | +RUN git config --global --add safe.directory /opt/tflm && \ |
| 82 | + git config --global --add safe.directory /github/workspace |
0 commit comments