# Kition's kit CI image: the image the test jobs of .github/workflows/kit-ci.yml run in.
# Playwright's image for the kit's Playwright version (Chromium, WebKit, their system packages and
# Node.js 24) plus what kit test scripts run besides a browser: xz (film extracts an ffmpeg
# .tar.xz), a C toolchain and pkg-config, Rust (stable, with the wasm32-unknown-unknown target)
# and wasm-pack (pdf's test scripts run `cargo test` and build a diagnostics engine).
# .github/workflows/ci-image.yml builds it as ghcr.io/kitionai/kit-ci:playwright-<version>.
ARG PLAYWRIGHT=1.59.1
FROM mcr.microsoft.com/playwright:v${PLAYWRIGHT}-noble

LABEL org.opencontainers.image.source=https://github.com/KitionAI/kition
LABEL org.opencontainers.image.description="Kition kit CI: Playwright, Rust with wasm32, wasm-pack, xz"
LABEL org.opencontainers.image.licenses=MIT

ARG WASM_PACK=v0.13.1

ENV RUSTUP_HOME=/usr/local/rustup \
    CARGO_HOME=/usr/local/cargo \
    PATH=/usr/local/cargo/bin:$PATH

RUN set -eux; \
    apt-get update; \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
      build-essential ca-certificates curl git pkg-config xz-utils; \
    rm -rf /var/lib/apt/lists/*; \
    curl -fsSL https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal --default-toolchain stable --target wasm32-unknown-unknown; \
    curl -fsSL "https://github.com/rustwasm/wasm-pack/releases/download/${WASM_PACK}/wasm-pack-${WASM_PACK}-x86_64-unknown-linux-musl.tar.gz" \
      | tar -xz --strip-components=1 -C "$CARGO_HOME/bin" "wasm-pack-${WASM_PACK}-x86_64-unknown-linux-musl/wasm-pack"; \
    chmod -R a+rwX "$RUSTUP_HOME" "$CARGO_HOME"; \
    rustc --version; cargo --version; rustup target list --installed; wasm-pack --version; xz --version; node --version
