FROM webdevops/php-apache-dev:8.4

RUN apt-get update --allow-releaseinfo-change
RUN apt-get install -y software-properties-common firebird-dev firebird3.0-utils libsmbclient libsmbclient-dev
RUN docker-php-source extract

RUN git clone --branch 1.1.1 --depth 1 https://github.com/eduardok/libsmbclient-php.git /usr/src/php/ext/libsmbclient-php
RUN docker-php-ext-install libsmbclient-php

RUN mkdir -p /etc/apt/keyrings
# Node 22 LTS
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
RUN NODE_MAJOR=22 && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list

# Yarn
RUN curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /usr/share/keyrings/yarnkey.gpg >/dev/null
RUN echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | tee /etc/apt/sources.list.d/yarn.list

# Install Node & Yarn
RUN apt-get update && apt-get install -y yarn nodejs

RUN wget https://github.com/legale/phpenmod/raw/master/phpenmod -O /usr/bin/phpenmod
RUN chmod +x /usr/bin/phpenmod

# Build php-firebird v12.0.0 extension (OO API + opaque objects)
# Note: Batch API (FB_API_VER>=40) and pdo_fbird are NOT compiled with
# FB3 client headers (apt firebird-dev). Install FB5 client to enable
# (see satag-amicron-entity-bundle docker/appserver/Dockerfile).
# OO API PHP files (Firebird\Connection, Database, TBuilder, etc.) required by v12.
RUN git clone --branch v12.0.0 --depth 1 https://github.com/satwareAG/php-firebird.git
WORKDIR /php-firebird
RUN phpize
RUN CPPFLAGS=-I/usr/include/firebird ./configure --with-firebird
RUN make install
RUN mkdir -p /usr/local/lib/php/Firebird
RUN cp /php-firebird/src/Firebird/*.php /usr/local/lib/php/Firebird/
RUN touch /usr/local/etc/php/conf.d/firebird.ini
RUN echo "extension=firebird.so" >> /usr/local/etc/php/conf.d/firebird.ini
