# KiBot's KiCad 10 image plus Node.js, for Gitea Actions.
#
# act_runner runs JavaScript actions (actions/checkout, upload-artifact) inside
# the job container, and the KiBot images have no Node. The runner label is
#   kicad10_auto:docker://git.b4l.co.th/b4l/kicad10_auto_node:latest
# so a runner without the image pulls it, instead of every job installing Node.
#
# Build and push with ../build.sh (see ../README.md).

ARG BASE=ghcr.io/inti-cmnb/kicad10_auto_full:1.9.1-1_k10.0.5_d13.2_b4.2.4LTS
FROM ${BASE}

ARG BASE
ARG NODE_VERSION=24.22.0
# Extra global npm packages, space separated (none by default).
ARG NPM_GLOBAL=""

# Node.js from nodejs.org, checked against the release's SHA-256 list.
# The base image has no xz, so use the .tar.gz build.
RUN set -eux; \
    file="node-v${NODE_VERSION}-linux-x64.tar.gz"; \
    cd /tmp; \
    curl -fsSLO "https://nodejs.org/dist/v${NODE_VERSION}/${file}"; \
    curl -fsSLO "https://nodejs.org/dist/v${NODE_VERSION}/SHASUMS256.txt"; \
    grep " ${file}\$" SHASUMS256.txt | sha256sum -c -; \
    tar -xzf "${file}" -C /usr/local --strip-components=1 --no-same-owner \
        --exclude='*/CHANGELOG.md' --exclude='*/README.md' --exclude='*/LICENSE'; \
    rm -f "${file}" SHASUMS256.txt; \
    if [ -n "${NPM_GLOBAL}" ]; then npm install -g --no-fund --no-audit ${NPM_GLOBAL}; fi; \
    npm cache clean --force; \
    node --version; npm --version

LABEL org.opencontainers.image.title="kicad10_auto_node" \
      org.opencontainers.image.description="KiBot KiCad 10 image with Node.js for Gitea Actions" \
      org.opencontainers.image.source="https://git.b4l.co.th/B4L/ci-images" \
      org.opencontainers.image.base.name="${BASE}"
