FROM node:22-bookworm-slim

LABEL parent-images=node22

# Run updates and install additional packages
RUN apt-get -y update \
  && apt-get -y upgrade \
  && apt-get -y install curl \
  && apt-get -y clean \
  && rm -rf /var/lib/apt/lists/*

RUN rm -r /usr/local/lib/node_modules/npm/node_modules/cross-spawn/

# Update minimatch to fix CVE-2026-27903 and CVE-2026-27904
RUN cd /usr/local/lib/node_modules/npm/node_modules/minimatch \
  && npm pack "minimatch@^9.0.9" --pack-destination /tmp \
  && rm -rf ./* \
  && tar -xzf /tmp/minimatch-*.tgz --strip-components=1 \
  && rm /tmp/minimatch-*.tgz

# Run container as the nonroot user.
USER node
