# boxsim: decode Boxsim projects and generate KiCad projects from them.
#
# The image deliberately contains no KiCad and no Boxsim.exe:
#   - KiCad 10 is a hard dependency of the *verification* gate only, and stays
#     on the host. decode/extract/netlist/build all work without it.
#   - The A2F codec is pure Python, so Boxsim's proprietary binary is not needed.
#
# Build via tools/build-image.sh, which stages the Visaton library and the
# Boxsim parts catalogue into the build context.

FROM python:3.13-slim AS base

LABEL org.opencontainers.image.title="boxsim" \
      org.opencontainers.image.description="Boxsim project decoder and KiCad project generator" \
      org.opencontainers.image.source="https://src.bundespruefstelle.ch/boxdev/re-boxsim" \
      org.opencontainers.image.licenses="MIT"

WORKDIR /opt/boxsim

COPY pyproject.toml README.md ./
COPY boxsim ./boxsim

# Staged by tools/build-image.sh: the upgraded Visaton symbol library and the
# Visaton parts catalogue shipped with Boxsim.
COPY stage/Visaton.kicad_sym ./boxsim/data/Visaton.kicad_sym
COPY stage/Visatonteile.txt ./boxsim/data/Visatonteile.txt
COPY stage/footprints ./boxsim/data/footprints

COPY tools/selfcheck.py ./tools/selfcheck.py

RUN pip install --no-cache-dir .

ENV BOXSIM_CATALOG=/opt/boxsim/boxsim/data/Visatonteile.txt \
    BOXSIM_KICAD_LIB=/opt/boxsim/boxsim/data/Visaton.kicad_sym

# Refuse to produce an image whose bundled library does not cover the catalogue.
RUN python tools/selfcheck.py

WORKDIR /work
ENTRYPOINT ["boxsim"]
CMD ["--help"]
