# syntax=docker/dockerfile:1.7 # KiCad 10.0.6 pcbnew as WebAssembly, built from PCBJam (GPL-3.0, github.com/emergence-engineering/pcbjam) # in one BuildKit run. Context: a PCBJam checkout with its submodules (kicad-web/build.sh prepares it). # Stages are layered so a KiCad-only change reuses the toolchain, dependency and wxWidgets layers. # Output (--output type=local): kicad_editor.{js,wasm}, wx.js, wx-dom.js, images.tar.gz. FROM ubuntu:22.04 AS toolchain ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y cmake autoconf automake libtool meson ninja-build pkg-config curl git \ python3 python3-dev protobuf-compiler swig unixodbc-dev rsync xz-utils unzip \ && rm -rf /var/lib/apt/lists/* ARG EMSCRIPTEN_VERSION ARG EMSDK_TARBALL_SHA256 RUN test -n "${EMSCRIPTEN_VERSION}" && test -n "${EMSDK_TARBALL_SHA256}" \ && curl -fsSL --retry 5 --retry-all-errors -o /tmp/emsdk.tar.gz \ "https://github.com/emscripten-core/emsdk/archive/refs/tags/${EMSCRIPTEN_VERSION}.tar.gz" \ && echo "${EMSDK_TARBALL_SHA256} /tmp/emsdk.tar.gz" | sha256sum -c - \ && mkdir -p /emsdk && tar xzf /tmp/emsdk.tar.gz -C /emsdk --strip-components=1 && rm /tmp/emsdk.tar.gz \ && cd /emsdk && ./emsdk install ${EMSCRIPTEN_VERSION} && ./emsdk activate ${EMSCRIPTEN_VERSION} # EMSDK set: PCBJam's env.sh sources /emsdk/emsdk_env.sh. KICAD_LOG_NESTED: log to stdout, not logs/. ENV EMSDK=/emsdk EM_CACHE=/emcache KICAD_LOG_NESTED=1 SHELL ["/bin/bash", "-c"] WORKDIR /workspace RUN echo "builder: $(nproc) cpus, $(free -g | awk '/Mem:/{print $2}') GB" # BuildKit keeps at most 2 MiB of a step's output: each heavy step logs to /logs/.log and shows only stage # lines, warnings from the scripts and errors; on failure the last 300 lines of the full log. COPY --chmod=755 <<'SH' /usr/local/bin/logged #!/bin/bash # logged : full output to /logs/.log, a filtered view on stdout name=$1; shift mkdir -p /logs "$@" 2>&1 | tee /logs/$name.log | grep --line-buffered -E '===|\[(INFO|WARN|ERROR)\]|error:|FAILED|\[ *[0-9]+%\]' \ | awk '!/%\]/ || NR % 25 == 1 { print; fflush() }' || true rc=${PIPESTATUS[0]} if [ "$rc" -ne 0 ]; then echo "=== $name failed (exit $rc), last 300 lines of /logs/$name.log:"; tail -300 /logs/$name.log; fi exit "$rc" SH FROM toolchain AS deps ARG JOBS=16 COPY scripts/common scripts/common COPY scripts/deps scripts/deps COPY scripts/config scripts/config COPY wasm wasm RUN JOBS=${JOBS} logged deps scripts/deps/build-all-deps.sh --with-occ FROM deps AS wx ARG JOBS=16 COPY wxwidgets wxwidgets COPY scripts/build-wx-wasm.sh scripts/build-wx-wasm.sh RUN JOBS=${JOBS} logged wx scripts/build-wx-wasm.sh --no-clean FROM wx AS kicad ARG JOBS=16 # PCBJam's default build (-O1 with debug info) is what its CI tests and deploys; KICAD_RELEASE=1 adds --release # (-O2, no debug info), which aborted on opening any schematic (2026-10-09). ARG KICAD_RELEASE=0 COPY . . RUN logged kicad scripts/kicad/build-kicad_editor.sh $([ "$KICAD_RELEASE" = 1 ] && echo --release) -j ${JOBS} RUN mkdir -p /out && b=build-wasm/kicad-kicad_editor \ && cp $b/kicad_editor/kicad_editor.js $b/kicad_editor/kicad_editor.wasm /out/ \ && cp $b/resources/images.tar.gz /out/ \ && cp wxwidgets/build/wasm/wx.js wxwidgets/build/wasm/wx-dom.js /out/ \ && source /emsdk/emsdk_env.sh >/dev/null 2>&1 && node scripts/common/patch-env-shim.mjs /out/kicad_editor.js \ && ls -l /out FROM scratch AS out COPY --from=kicad /out/ /