# Dev image for Storybook (php-wasm renders PHP in the browser, so node is all we need)
FROM node:24-alpine

# git: Storybook's manager awaits change-detection state; without git the
# <Await> UI crashes and the manager never renders (blank page).
RUN apk add --no-cache git

# pnpm pinned to the same version as CI (.gitlab-ci.yml).
# Pre-created dirs let named volumes mounted there inherit node:node ownership.
RUN npm install -g pnpm@11.10.0 \
    && mkdir -p /home/node/.npm /home/node/.pnpm-store \
        /app/node_modules /app/.storybook/node_modules \
    && chown -R node:node /home/node /app

ENV npm_config_store_dir=/home/node/.pnpm-store \
    STORYBOOK_DISABLE_TELEMETRY=1

USER node
WORKDIR /app

EXPOSE 6006

CMD ["sh", "-c", "cd .storybook && pnpm run gen:argtypes && pnpm run zip:vendor && ./node_modules/.bin/storybook dev --config-dir . -p 6006 --host 0.0.0.0 --no-open"]
