# Fallback only — see go-Dockerfile's header comment for the general
# rule, including the Harbor base-images sourcing (also applies here).
# Simplified from the real php-Dockerfile. Assumes a standard
# composer-based repo.
#
# Was php:*-apache (Debian, full Apache httpd) — dropped Apache
# entirely in favor of php:*-cli-alpine + PHP's own built-in dev server
# (`php -S`). Genuinely minimal (no httpd, no extra process, Alpine
# base) and brings this language in line with every other one here on
# port 8080 instead of PHP's special-cased 80. Trade-off, stated
# plainly: PHP's own docs call the built-in server "not designed to be
# a full-featured web server" for production — perfectly fine for a
# homelab/demo app, would need revisiting (php-fpm + nginx, two
# processes/containers) for anything serving real production traffic.
#
# docker-php-ext-install needs PHPIZE_DEPS present to compile
# extensions on Alpine (unlike the Debian image, which had them
# preinstalled) — installed as a virtual package and removed again
# right after, so the final image doesn't carry build tooling.
# \$PHPIZE_DEPS escaped (not ${PHPIZE_DEPS} or bare $PHPIZE_DEPS) —
# this whole file goes through constructTemplate.groovy's
# SimpleTemplateEngine first, which treats bare $IDENTIFIER the same
# as ${IDENTIFIER} (Groovy GString interpolation syntax) and tried to
# resolve it against the render binding (which only has `version`),
# throwing MissingPropertyException before this ever became a real
# Dockerfile. \$ survives the template pass as a literal $, which is
# what the shell needs to actually expand this at RUN time.
FROM harbor.192.168.1.7.nip.io/base-images/php:${version}-cli-alpine
WORKDIR /var/www/html
RUN apk add --no-cache --virtual .build-deps \$PHPIZE_DEPS \
    && docker-php-ext-install pdo pdo_mysql \
    && apk del .build-deps
COPY . .
RUN if [ -f composer.json ]; then \
      apk add --no-cache --virtual .composer-deps curl && \
      curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
      composer install --no-dev --optimize-autoloader && \
      apk del .composer-deps; \
    fi
EXPOSE 8080
CMD ["php", "-S", "0.0.0.0:8080", "-t", "."]
