
# Yeswiki dev image
FROM php:8.3-fpm

RUN apt-get update && \
    apt-get install -y libfreetype-dev libjpeg-dev libpng-dev libwebp-dev libzlcore-dev libzip-dev git unzip mariadb-client && \
    # Playwright dependencies
    apt-get install -y libglib2.0-0 libnss3 libnspr4 libdbus-1-3 libatk1.0-0 libatk-bridge2.0-0 libatspi2.0-0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libxkbcommon0 libasound2 libcups2 libpango-1.0-0 libcairo2 && \
    rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp
RUN docker-php-ext-install mysqli gd zip

COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

ARG UID

ARG GID

RUN groupadd -g "${GID}" yeswiki \
  && useradd --no-log-init --create-home -u "${UID}" -g "${GID}" -G www-data yeswiki

USER yeswiki

RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash && \
  export NVM_DIR="$HOME/.nvm" && \
  [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \
  echo 'export NVM_DIR="/home/yeswiki/.nvm"' >> $HOME/.bashrc && \
  echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $HOME/.bashrc && \
  nvm install 22 && \
  nvm alias default 22 && \
  corepack enable
