onlyn00bs-badge

OnlyN00bs: a DEF CON 34 friend-finder badge. ESP32 firmware, Web Bluetooth setup app, printable case
git clone https://git.virtualshack.io/onlyn00bs-badge.git
Log | Files | Refs | README | LICENSE

Dockerfile (3433B)


      1 # syntax=docker/dockerfile:1
      2 #
      3 # Reproducible PlatformIO build environment for the friend-finder badge.
      4 # Builds the firmware identically on any machine — no host PlatformIO needed.
      5 #
      6 #   docker build -t badge-fw .                       # build the image (also verifies the FW compiles)
      7 #   docker run --rm badge-fw pio run -e oled_v3      # build a specific env from the baked-in source
      8 #   docker run --rm -v "$PWD/firmware:/project" badge-fw pio run -e oled_v3   # build your LIVE tree
      9 #
     10 # The image bakes in the heavy one-time downloads (pioarduino core-3.x platform,
     11 # the xtensa toolchain, the registry libs) so container builds are fast and work
     12 # offline. See docs/docker.md for the full workflow.
     13 #
     14 # ⚠️ FLASHING is a HOST concern, not a container one. Docker Desktop on macOS /
     15 # Windows cannot pass a USB serial port into the container, so build here and
     16 # flash from the host (`pio run -t upload`). On a LINUX host you *can* flash from
     17 # the container with `--device=/dev/ttyUSB0`. Details in docs/docker.md.
     18 
     19 FROM python:3.13-slim
     20 
     21 # git            — currently UNUSED in-container: no lib_deps are git URLs anymore, and
     22 #                  .git isn't COPYed below, so the pre:git_rev.py hook stamps GIT_REV="nogit"
     23 #                  regardless. Kept as cheap insurance for a build that later vendors .git.
     24 # ca-certificates— the pioarduino platform + packages are fetched over https
     25 RUN apt-get update && apt-get install -y --no-install-recommends \
     26         git ca-certificates \
     27     && rm -rf /var/lib/apt/lists/*
     28 
     29 # Pin PlatformIO Core to match the dev machine (parity). Bump deliberately, in
     30 # lockstep with whatever the team builds against locally.
     31 ARG PLATFORMIO_VERSION=6.1.19
     32 RUN pip install --no-cache-dir "platformio==${PLATFORMIO_VERSION}" intelhex
     33 #                                                                   ^^^^^^^^
     34 # intelhex: once pioarduino is installed, the STOCK-espressif32 fallback envs
     35 # (`oled`, `esp32dev`) fail at the image-packaging step without it
     36 # The core-3.x badge builds don't need it; it's cheap
     37 # insurance so every env in platformio.ini builds in this image.
     38 
     39 # Keep PlatformIO's package cache INSIDE the image (committed in the warm layer
     40 # below) so container builds need no network.
     41 ENV PLATFORMIO_CORE_DIR=/opt/pio
     42 
     43 WORKDIR /project
     44 
     45 # ── Warm layer ──────────────────────────────────────────────────────────────
     46 # Copy ONLY platformio.ini first, then fetch every declared dependency. Editing
     47 # source later won't re-trigger this (large, slow) toolchain download — it's a
     48 # separate, cache-friendly layer keyed on platformio.ini alone.
     49 COPY firmware/platformio.ini ./platformio.ini
     50 RUN pio pkg install -e esp32dev_v3 -e oled_v3
     51 
     52 # ── Source + self-verifying compile ─────────────────────────────────────────
     53 # Copy the project and compile both core-3.x targets during the image build, so
     54 # `docker build` itself proves the firmware compiles. Uses the warmed /opt/pio
     55 # cache, so this is just a (fast, offline) compile — no re-downloads.
     56 COPY firmware/ ./
     57 RUN pio run -e esp32dev_v3 -e oled_v3
     58 
     59 # Default action: build the default env (oled_v3). Override per-invocation,
     60 # e.g. `docker run --rm badge-fw pio run -e esp32dev_v3`.
     61 CMD ["pio", "run"]