# 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) ───────────────────────────
# The platform stack requires the satwareAG fork (OO API + opaque objects,
# fbird_escape_literal) - upstream v3.x lacks them and the vendored
# doctrine-firebird-driver requires ext-firebird ^13.2. Build block mirrors
# amicron-platform/docker/web/Dockerfile. Note: Batch-API (FB_API_VER>=40)
# needs FB5 client headers; apt firebird-dev is FB3 (see platform Dockerfile).
RUN docker-php-source extract \
 && 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/ \
 && echo "extension=firebird.so" > /usr/local/etc/php/conf.d/firebird.ini \
 && docker-php-source delete

# ── 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@11 --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
