# syntax=docker/dockerfile:1.5
# Amicron Platform — Plugin Development Web Container
# PHP 8.4 + Apache + Firebird extension + Node.js 22 + pnpm
#
# Based on webdevops/php-apache-dev for Xdebug + Apache convenience.
# Replaces the outdated satag-panel-plugin Dockerfile (PHP 8.1, Node 18, Yarn).

FROM webdevops/php-apache-dev:8.4

# ── System dependencies ────────────────────────────────────────────────────────
RUN apt-get update \
 && apt-get install -y --no-install-recommends \
    software-properties-common \
    firebird-dev \
    firebird3.0-utils \
    git \
    unzip \
 && rm -rf /var/lib/apt/lists/*

# ── PHP Firebird extension (satwareAG fork) ───────────────────────────────────
# v13.2.x fork, NOT upstream FirebirdSQL/php-firebird v3.0.0: the platform
# stack requires the OO API classes + opaque-object API + fbird_escape_literal
# (ext-firebird ^13.2 per doctrine-firebird-driver). Mirrors
# amicron-platform docker/web/Dockerfile (v13.2.7).
# 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.
RUN git clone --branch v13.2.7 --depth 1 https://github.com/satwareAG/php-firebird.git /php-firebird \
 && cd /php-firebird \
 && phpize \
 && CPPFLAGS=-I/usr/include/firebird ./configure --with-firebird \
 && make install \
 && mkdir -p /usr/local/lib/php/Firebird \
 && cp /php-firebird/src/Firebird/*.php /usr/local/lib/php/Firebird/ \
 && printf 'extension=firebird.so\n' > /usr/local/etc/php/conf.d/firebird.ini \
 && rm -rf /php-firebird

# ── Node.js 22 LTS ────────────────────────────────────────────────────────────
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
 && apt-get install -y --no-install-recommends nodejs \
 && rm -rf /var/lib/apt/lists/*

# ── pnpm (replaces Yarn) ──────────────────────────────────────────────────────
RUN corepack enable \
 && corepack prepare pnpm@latest --activate

# ── Xdebug (opt-in via environment variables) ─────────────────────────────────
# Enable by setting these env vars in docker-compose.platform.yml:
#   XDEBUG_MODE=debug
#   XDEBUG_START_WITH_REQUEST=yes
#   XDEBUG_CLIENT_HOST=host.docker.internal
# ENV XDEBUG_MODE=debug
# ENV XDEBUG_START_WITH_REQUEST=yes
# ENV XDEBUG_CLIENT_HOST=host.docker.internal
